If you really need to add items inside the loop then you should (properly) use another kind of loop (for instance a
for
, or a
while
, depending on your needs) to iterate on the items of the DataTable collection, e.g.
int COUNT = dt.Rows.Count;
for (int r = 0; r<COUNT; ++r)
{
DataRow dr = dr.Rows[r];
}