如何从数据集中获取特定列号。 [英] how can I get a specific column number from a dataset.

查看:72
本文介绍了如何从数据集中获取特定列号。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为dt的数据集。



我知道在这个数据集的数据表中有一个名为'User'的列。



如何我可以找到列名称为用户的列号吗?

I have a Dataset named dt.

I know that there is column named 'User' in the datatable of this dataset.

How can I find out the column number where the column name is 'User'?

推荐答案

这里的dt是一个DataTable。您可以从DataSet本身轻松获取它(请参阅这个 [ ^ ]),然后,

Here dt is a DataTable. You can easily get it from DataSet itself (see this[^]), and then,
if (dt.Columns.Contains("User"))
{
        // do something...
}



或者,


or else,

int i = dt.Columns.IndexOf("User");



-KR


-KR


这篇关于如何从数据集中获取特定列号。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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