如何仅显示数据表中的某些列? [英] How do I display only certain columns from a data table?

查看:27
本文介绍了如何仅显示数据表中的某些列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用返回数据集的 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 设置为 false.为 a3a4 创建 BoundColumns.

Ignore the fact that you have more data than you need. Set AutoGenerateColumns to false. Create BoundColumns for a3 and a4.

这篇关于如何仅显示数据表中的某些列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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