如何从填充的数据集中提取单列数据?

时间:2021-08-13 03:59:08

How do I pull a single column of data out of a filled dataset?

如何从填充的数据集中提取单列数据?

I have a filled dataset object, with a variety of tables. I need to get all of the data that is stored in a particular column in one of the tables, and bind a ComboBox ItemSource to it. (This may require me to pull the data out and make it into a string collection ...)

我有一个填充的数据集对象,有各种表。我需要获取存储在其中一个表中的特定列中的所有数据,并将ComboBox ItemSource绑定到它。 (这可能需要我将数据拉出并将其转换为字符串集合...)

If anyone has any bright ideas, it would be very grateful!

如果有人有任何好主意,那将非常感激!

1 个解决方案

#1


I assume this is ASP.Net....slightly different for windows forms... Set the comobobox datasource to the specific table in the dataset and then set the datavalue/datatext fields to the string name of the columns that you want for the value/display text.

我假设这是ASP.Net ....对于Windows窗体略有不同...将comobobox数据源设置为数据集中的特定表,然后将datavalue / datatext字段设置为所需的列的字符串名称值/显示文字。

ComboBox1.DataSource = myDataTable.tables(0)
ComboBox1.DisplayMember = "Field Name" 'the field you want to show in combo box.

#1


I assume this is ASP.Net....slightly different for windows forms... Set the comobobox datasource to the specific table in the dataset and then set the datavalue/datatext fields to the string name of the columns that you want for the value/display text.

我假设这是ASP.Net ....对于Windows窗体略有不同...将comobobox数据源设置为数据集中的特定表,然后将datavalue / datatext字段设置为所需的列的字符串名称值/显示文字。

ComboBox1.DataSource = myDataTable.tables(0)
ComboBox1.DisplayMember = "Field Name" 'the field you want to show in combo box.