数据网格中有2个数据源? [英] 2 datasources in a datagrid?

查看:70
本文介绍了数据网格中有2个数据源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!

有没有一种方法可以在一个数据网格中使用2个不同的数据源?

我希望有一个源绑定到我的datagrid中的标头

另一个源绑定到行?

有可能这样做吗,有人举个例子吗?

谢谢!

Hello!

Is there a way to use 2 different datasources in one datagrid?

i want one source to bind to the headers in my datagrid

and the other source to bind to the rows?

is it possible to do this, does anyone have an example?

Thanks!

推荐答案

你好,亲爱的,

对于标题,没有使用不同的数据源.您可以使用数据源绑定数据,该数据将自动以数据集标题名称作为标题.如果不想显示某些列,则可以通过row_intialization事件中的hidden属性将其隐藏.
Hello Dear,

For the header there is no use of using a different datasource. You can use your datasource to bind the data it will take automatically the dataset header name as the header. If you want not to show some columns then you can hide it by the hidden property in row_intialization event.


我通过更改后面代码中的所有列标题来保存它,我更愿意通过数据绑定解决它,但是无论如何它都起作用.

I soved it by changing all the column headers in the code behind, i would prefered to solve it with data binding but anyway it works.

this.datagridname.Columns[0].header = "headertext";



我只是用数据源中的字符串来更改所有列的标题文本.



I just change the headertext on all my columns this with the string from my datasource.


这篇关于数据网格中有2个数据源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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