如何显示从数据表中只有某些列? [英] How do I display only certain columns from a data table?
本文介绍了如何显示从数据表中只有某些列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的返回数据集的Web服务。在此数据集有5个表,假设表A,B,C,D,E。我用表A中。
I'm using a web service that returns a dataset. in this dataset there are 5 table, let's say table A, B, C, D, E. I use table A.
于是
DataTable dt = new DataTable()
dt = dataset.Table["A"]
现在在此数据表中有列A1,A2,A3,A4,A5,A6,A7。
Now in this datatable there are columns a1,a2,a3,a4,a5,a6,a7.
比方说,我只是想获得列A3和A4,然后将其绑定到我的数据网格。
Let's say I only want to get columns a3 and a4 then bind it to my datagrid.
我如何做到这一点?
推荐答案
忽略,你有比你需要更多的数据的事实。设置的AutoGenerateColumns
到假
。创建 BoundColumns
为 A3
和 A4
。
Ignore the fact that you have more data than you need. Set AutoGenerateColumns
to false
. Create BoundColumns
for a3
and a4
.
这篇关于如何显示从数据表中只有某些列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文