如果我有一个包含500条记录的数据表,我怎样才能一次循环这100条记录并将列值绑定到变量?
目前我正在像这样循环遍历整个数据表
foreach (DataRow row in customerTbl.Rows)
{
int customerId = Convert.ToInt32(row["id"]);
// perfom some action based on ID
}
如何将其与此类结合起来?
for (int r = 0; r < customerTbl.Rows.Count; r += 500)
{
}
答案 0 :(得分:2)
嗯,你总是可以这样做:
for (int r = 0; r < customerTbl.Rows.Count; r += 100)
{
DataRow dr = customerTbl.Rows[r];
//do stuff
}