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
设置为 false
.为 a3
和 a4
创建 BoundColumns
.
Ignore the fact that you have more data than you need. Set AutoGenerateColumns
to false
. Create BoundColumns
for a3
and a4
.
这篇关于如何仅显示数据表中的某些列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何仅显示数据表中的某些列?


基础教程推荐
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 如何激活MC67中的红灯 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01