Home > C# Programming Tips > Get Order & Name Of a DataTable Column

Get Order & Name Of a DataTable Column

DataTable myDataTable=new DataTable();
//To get the name of a column .If u dont know the column name use column no
string currentColumnName = myDataTable.Columns["Col1"].ColumnName;
//To get the Rank Or Column No
// then pick the column no of this column and save it as the value
int rank = myDataTable.Columns[currentColumnName].Ordinal;

Advertisements
Categories: C# Programming Tips
  1. April 13, 2011 at 8:33 am

    Thanks for the article I truly learned some thing from it. Excellent articles on this web site Often searching forward to new post.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: