Column value?

  • Thread starter Thread starter Mervin Williams
  • Start date Start date
M

Mervin Williams

How do you retrieve the value of a column in the current datarow object in a
dataset?
 
foreach(DataRow dro in DataTable.Rows){
string s = dro[ColumnIndex].ToString();
string s2 = dro["ColumnNameInQuotes"].ToString();//both yeild the same
result although the first way is much faster. If you want to sue
columnnames, use Bill Vaughn's method and create an enum where the
columnname corresponds to the index. Then you can effectively use the
"ColumnName" but get the efficiency of using the index.

//Also, I just casted to string, you'll need to adjust this to your needs

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top