So instead of using the following code which will fail
//Wrong Code dont use this .. this will Fail
foreach (DataRow orow in dataTable.Rows) { if ((orow["ID"].ToString()).Equals("2")) { dataTable.Rows.Remove(orow); } }Instead of using the above code use Select() as shown below
//Correct code use this
foreach (DataRow orow in dataTable.Select()) { if ((orow["ID"].ToString()).Equals("2")) { dataTable.Rows.Remove(orow); } }Check this Fiddle
Leave a Comment. Bob