I am currently trying to use the delete method and then the accept changes method but am having problems.
I am trying to locate a row in the datatable to delete but am not sure how to go about this. I have decided to use a for loop to iterate through the datatable until a match is found with the entered ID number. However, when the matching ID number is found, the code that I use to delete the found row doesnt seem to work. I get a thrown exception saying that the row at position (n)does not exist in the table and the datagrid on the form goes blank.
The code that I am using to try to delete the found row is shown below.
int RowCount = 0;
foreach(DataRow dr in mydataset.Tables.Rows)
if (txtStudID.Text == dr.ToString())
} //end of for loop
f2.dataGrid1.DataSource = mydataset;
Any help will be very much appreciated.