运行代码时,它仅遍历tableSiblings.Rows中一小部分行
我也尝试使用for代替foreach(当然更改()的内部),但仍然无法正常工作。 我该怎么办?
dsSiblings = dal.GetDataSet("Select * From Siblings");
// Go through the table:
foreach (DataGridViewRow row in tableSiblings.Rows)
{
// If this is a new row:
if ((row.Cells["siblingID"].Value ?? string.Empty).ToString() == string.Empty.ToString())
{
DoSomething();
}
else
{
// Go through the database:
foreach (DataRow dr in dsSiblings.Tables[0].Rows)
{
// If a sibling with the same ID exists:
if ((row.Cells["siblingID"].Value ?? string.Empty).ToString() == dr["siblingID"].ToString())
{
DoSomethingElse();
break;
}
}
}
}
dal.UpdateDataSet(dsSiblings);