↑ Grab this Headline Animator

Friday, May 9, 2008

How to loop through all rows of the DataTable?

You can do this in more than one way but ForEach loop is much better than any other way in terms of cleanliness of the code or performance.

ForEach loop

foreach(DataRow row in dTable.Rows)
yourvariable = row["ColumnName"].ToString();
}For loop

for (int j = 0; j< dTable.Rows.Count; j++)
yourvariable = dTable.Rows[j]["ColumnName"].ToString()l

Submit this story to DotNetKicks

No comments:

Post a Comment

Post your comments/questions/feedback for this Article.


Latest Articles