How to access deleted rows in DataTable/DataSet

Posted by Tripati.patro under C# category on | Points: 40 | Views : 11631
If you access the deleted row direcly, you will get an exception saying that the row has been deleted.
We canget the information from the original version of the row by specifying DataRowVersion.Original .

Different Way of accessing the deleted row
// dataRow is the deleted row.
if (dataRow.RowState == DataRowState.Deleted)
id = (string)dataRow["EmpId", DataRowVersion.Original];

// Assume dtEmployee is already created DataTable
var deletedRows = dtEmployee.Select("","",DataViewRowState.Deleted);

// Get Only Deleted Rows in DataTable
DataView dv = new DataView(dtEmployee, null, null, DataViewRowState.Deleted);

Comments or Responses

Login to post response