Posted By

czapata on 04/23/08


Tagged

dotnet


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

umang_nine
derekholmes


DataRow Column Iterator


 / Published in: C#
 

  1. foreach(DataRow row in dr.Table.Rows)
  2. {
  3. int colCount=0;
  4. foreach(DataColumn column in dr.Table.Columns)
  5. {
  6. Response.Write(dr.Table.Columns[colCount].ColumnName + ": " + dr[column].ToString() + "<br />");
  7. colCount ++;
  8. }
  9. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: derekholmes on May 26, 2010

wouldn't this be easier?

foreach(DataRow row in dr.Table.Rows) { foreach(DataColumn column in dr.Table.Columns) { Response.Write(column.ColumnName + ": " + dr[column].ToString() + ""); } }

You need to login to post a comment.