« System.Type.Missing | Main | Indonesian government pays $1 per unlicensed Windows XP »
June 06, 2005
Accessing DataRow after it has been deleted
Normally when you tried to access the Item property of a DataRow after it has been deleted it will throw a DeletedRowInaccessibleException. For example:
DataRow row = dataTable.Rows[0];
row.Delete();
// This will throw DeletedRowInaccessibleException
long id = row["Id"];
However what the documentation does not say is that if you use the DataRowVersion.Original when accessing the Item property it'll work. For example:
DataRow row = dataTable.Rows[0];
row.Delete();
// This is OK
long id = row["Id", DataRowVersion.Original];
Nice trick, I've only found this out today.
Posted by vhadiant at June 6, 2005 10:14 PM
