Datagrid绑定 [英] Datagrid binding

查看:72
本文介绍了Datagrid绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我试图从列表框中将数据绑定到我的数据网格,我认为它应该可以工作但是会出现错误,说我必须绑定到
$ b实现Inumerable或icollection的$ b数据源...但我认为列表

盒子确实实现了上述之一,因为他们确实有他们的物品集合

property,

有人可以帮忙吗?

hi all i am trying to bind data to my datagrid from a listbox which i think
it should work but an error is coming up saying i have to bind to a
datasource that implements the Inumerable or icollection...but i thought list
boxes did implement one of the above as they do have their items collection
property,
can anyone help?

推荐答案

ShadowsOfTheBeast写道:
ShadowsOfTheBeast wrote:
大家好我是试图从列表框中将数据绑定到我的数据网格,我认为它应该可以工作,但是出现了一个错误,说我必须绑定到实现Inumerable或icollection的
数据源......但我想
列表
盒子确实实现了上面的一个,因为他们确实有他们的物品收藏
属性,
hi all i am trying to bind data to my datagrid from a listbox which i think
it should work but an error is coming up saying i have to bind to a
datasource that implements the Inumerable or icollection...but i thought
list
boxes did implement one of the above as they do have their items collection
property,




我不是完全确定我理解正确 - 一些示例代码

关于你正在做的事情可能有所帮助。但我假设您正在尝试将
直接将列表框绑定到网格中,如下所示:


myDataGrid.DataSource = myListBox;


这不行,因为它不是实现

集合接口的列表框,它只是Items属性返回的对象。 br />
这是一个与ListBox一起使用的特殊集合,它实现了

IList。所以你应该没问题,如果你使用这样的一行进行绑定:

myDataGrid.DataSource = myListBox.Items;

Oliver Sturm
-

omnibus ex nihilo ducendis sufficit unum

插入空间以防止谷歌电子邮件销毁:

MSN oliver @ sturmnet。 org Jabber sturm @ amessage.de

ICQ 27142619 http:// www .sturmnet.org / blog


嗨奥利弗谢谢你的帮助我有点想到了分钟

之后...但是我实际上要做的是:


i有一个列表框控件,可以从另一个列表框中获取数据(因此从第一个选择中获取
a子集列表框)我有一个数据网格

有一个模板列和一个绑定列,我想绑定绑定列到

第二个列表框然后它的模板列实现下拉列表
每个绑定列项的
,现在这个下拉列表(在数据网格的
的模板列中)我想将它绑定到数据集的数据表

" Oliver Sturm"写道:
hi oliver thanks for your help i kinda figured that out minutes
afterwards...but what i am actually trying to do is this:

i have a listbox control that gets its data from another listbox (hence gets
a subset by selecting from the first list box) and i have a datagrid which
has a template column and a bound column, i want to bind the bound column to
this second listbox and then its template column implements a dropdownlist
for every bound column item, now this dropdownlist (in the template column of
the datagrid) i want to bind it to a dataset''s datatable

"Oliver Sturm" wrote:
ShadowsOfTheBeast写道:
ShadowsOfTheBeast wrote:
大家好我试图从列表框中将数据绑定到我的数据网格,我认为
它应该工作,但一个错误即将来临,说我必须绑定到实现Inumerable或icollection的
数据源......但我认为
list
盒子确实实现了上述之一他们确实有他们的物品收藏
属性,
hi all i am trying to bind data to my datagrid from a listbox which i think
it should work but an error is coming up saying i have to bind to a
datasource that implements the Inumerable or icollection...but i thought
list
boxes did implement one of the above as they do have their items collection
property,



我不能完全确定我是否理解正确 - 关于你在做什么的一些示例代码
可以帮助。但我假设您正在尝试将列表框直接绑定到网格,如下所示:

myDataGrid.DataSource = myListBox;

这不会因为它不是实现
集合接口的列表框,所以它只是Items属性返回的对象。
这是一个与ListBox一起使用的特殊集合,它实现了
IList。所以你应该没问题,如果你使用这样的一行进行绑定:

myDataGrid.DataSource = myListBox.Items;

Oliver Sturm
- <为了防止谷歌电子邮件遭到破坏而插入空间:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 omnibus ex nihilo ducendis sufficit unum
href =http://www.sturmnet.org/blogtarget =_ blank> http://www.sturmnet.org/blog



嗨奥利弗谢谢你的帮助我有点想出来了之后

之后......但我真正想做的是:


i有一个列表框控件,从另一个列表框中获取数据(因此从第一个列表框中选择,获得了
a子集)并且我有一个数据网格

有一个模板列和绑定列,我想将绑定列绑定到

第二个列表框,然后其模板列实现一个下拉列表,现在这个下拉列表(在数据网格的
的模板列中)我想将它绑定到数据集的数据表


我已经创建了一个从数据集中获取数据的下拉列表,但是如何在数据网格中实现这一点

< templatecolumn> < itemTemplate>

i似乎这样做可以请你帮忙吗?


" Oliver Sturm"写道:
hi oliver thanks for your help i kinda figured that out minutes
afterwards...but what i am actually trying to do is this:

i have a listbox control that gets its data from another listbox (hence gets
a subset by selecting from the first list box) and i have a datagrid which
has a template column and a bound column, i want to bind the bound column to
this second listbox and then its template column implements a dropdownlist
for every bound column item, now this dropdownlist (in the template column of
the datagrid) i want to bind it to a dataset''s datatable

I have already created a dropdownlist that gets the data from a dataset but
how do i implement this whithin the datagrid in a
<templatecolumn><itemTemplate>
i cant seem to do this can you please help?

"Oliver Sturm" wrote:
ShadowsOfTheBeast写道:
ShadowsOfTheBeast wrote:
大家好我试图从列表框中将数据绑定到我的数据网格,我认为
它应该工作,但一个错误即将来临,说我必须绑定到实现Inumerable或icollection的
数据源......但我认为
list
盒子确实实现了上述之一他们确实有他们的物品收藏
属性,
hi all i am trying to bind data to my datagrid from a listbox which i think
it should work but an error is coming up saying i have to bind to a
datasource that implements the Inumerable or icollection...but i thought
list
boxes did implement one of the above as they do have their items collection
property,



我不能完全确定我是否理解正确 - 关于你在做什么的一些示例代码
可以帮助。但我假设您正在尝试将列表框直接绑定到网格,如下所示:

myDataGrid.DataSource = myListBox;

这不会因为它不是实现
集合接口的列表框,所以它只是Items属性返回的对象。
这是一个与ListBox一起使用的特殊集合,它实现了
IList。所以你应该没问题,如果你使用这样的一行进行绑定:

myDataGrid.DataSource = myListBox.Items;

Oliver Sturm
- <为了防止谷歌电子邮件遭到破坏而插入空间:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 omnibus ex nihilo ducendis sufficit unum
href =http://www.sturmnet.org/blogtarget =_ blank> http://www.sturmnet.org/blog



这篇关于Datagrid绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆