[ACCEPTED]-How do You Get a Specific Value From a System.Data.DataTable Object?-system.data
Accepted answer
Just the basics....
yourDataTable.Rows[ndx][column]
where ndx is the row 4 number (starting at 0) where column can 3 be a DataColumn object, an index (column 2 n), or the name of the column (a string)
yourDataTable.Rows[0][0]
yourDataTable.Rows[0][ColumObject]
yourDataTable.Rows[0]["ColumnName"]
to 1 test for null, compare to DBNull.Value;
You mean like table.Rows[0]["MyColumnName"]
?
0
If you wan't to extract the row with it's 2 ID = 5(ie the Primary key) and get its value 1 for the Column called Description.
DataRow dr = myDataTable.Rows.Find(5);
String s = dr["Description"].ToString();
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.