I don't understand why this code does not work.
foreach (DataRow dataRow in dataTable.Rows) { if (true) { dataRow.Delete(); } }
Safest way - use for loop
for
for (int i = datatable.Rows.Count - 1; i >= 0; i--) { if (true) { datatable.Rows[i].Delete(); } }
Don't forget to AcceptChanges to remove all marked rows:
AcceptChanges
datatable.AcceptChanges();
1.4m articles
1.4m replys
5 comments
57.0k users