将数据表中的特定列添加到 gridview asp.net
add specific columns from datatable to gridview asp.net
我正在寻找 return 到 gridview 的数据表,但是我不需要 gridview 中数据表中的所有列。
以编程方式执行此操作的最佳方法是什么?
我现在的代码是这样的
Dim dt As DataTable = New DataTable()
dt = GetValues()
gvContactList.DataSource = dt
我需要 return 的列索引如下 0, 6, 7, 9
我们将不胜感激任何帮助。
创建一个临时数据table(其中包含您感兴趣的列)并使用实际 table.
中的行填充临时数据 table
现在将网格与数据源绑定为临时数据table。
我正在寻找 return 到 gridview 的数据表,但是我不需要 gridview 中数据表中的所有列。
以编程方式执行此操作的最佳方法是什么?
我现在的代码是这样的
Dim dt As DataTable = New DataTable()
dt = GetValues()
gvContactList.DataSource = dt
我需要 return 的列索引如下 0, 6, 7, 9
我们将不胜感激任何帮助。
创建一个临时数据table(其中包含您感兴趣的列)并使用实际 table.
中的行填充临时数据 table现在将网格与数据源绑定为临时数据table。