How do you get the Deleted DataRows of a DataSet?
Posted on 2005-04-07
My program uses DataRow.Delete to delete rows from a DataSet. After they have been deleted, I check it's RowState which is Deleted and then I call GetChanges() on the DataSet. The changes returned do not include the deleted rows. If I can't use GetChanges after a series of Delete()'s to find out what has changed in the DataSet, what can I use to find out wihch rows have been deleted. Do I need to keep track of the deletions myself?
My code to delete and get changes is below.
int rowIdx = dataGrid1.CurrentRowIndex;
DataSet ds = (DataSet)dataGrid1.DataSource;
DataRow rowToDelete = ds.Tables["Msgs"].Rows[rowIdx];
DataSet changes = ds.GetChanges();
if (changes != null)
string changesString = changes.GetXml();