Friday, 1 March 2013

How do I get current index in “for each” loop

Solutions 1:  
foreach (DataRow row in dtGroups.Rows)
{
    string grpTitle = row["MainCategory"].ToString();
    int  id = dtGroups.Rows.IndexOf(row);   // (row no)
}

No comments:

Post a Comment