Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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'?
Posted

1 solution

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

or else,
C#
int i = dt.Columns.IndexOf("User");

-KR
 
Share this answer
 
v4
Comments
sachi Dash 18-Feb-14 2:30am    
Thanks !!
Krunal Rohit 18-Feb-14 3:55am    
Glad I could help :)
-KR

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900