1
Answer

Why Datarow deleted rows is not accessible in datatable

Vanaraj n

Vanaraj n

8y
228
1
I am having 5 rows in a datatable, it is binded with datagrid on screen i deleted one row , then same datatable i am using in some other method by using foreach method when coming to deleted row it shows datarows not accessible exception. But i didnt called for database,anyway that records should be available for deleting in db why when using foreach read that row exception is coming.
Answers (1)
1
Amit Gupta

Amit Gupta

NA 16.5k 25.7k 8y
When any rows gets deleted, it still exists in the datatable untill dt.AcceptChanges () was called.
 
You can access the deleted rows by using below snippet
  1. if (dataRow.RowState == DataRowState.Deleted)  
  2.     id = (string)dataRow["EmpId", DataRowVersion.Original];