Directly Add code
Int proid1 = 0; foreach (datarow row1 in tables. rows) {If (convert. toint32 (row1 ["proid"]) = proid1) {row1.delete (); // tables. rows. remove (row1);} else {proid1 = convert. toint32 (row1 ["proid"]) ;}// submit the modified datatable tables. acceptchanges ();
If there are two data entries in the first column (505 506 507) that are deleted from column 6, the row with the value of Column 5 is retained.
Article 1: 505 3 3377 5 4
Article 2: 505 3 3377 6 5
Article 3: 506 3 3377 5 4
Article 5: 507 3 3377 5 4
Article 6: 507 3 3377 6 5
......................................
.....................................
Datatable. Rows. Remove cannot be used for loop traversal because it cannot damage its structure because it must be recycled.
Therefore, use tablerow. Delete () to mark it first, and then submit the modification using datatable. acceptchanges () after traversal.
Over