Site Search:
Sign in | Join | Help
4Penny.net

VB.NET

Notes, Tricks and Tips on VB.NET

Deleted row information cannot be accessed through the row

Deleted row information cannot be accessed through the row

Banged my head against this one for about 2 hours. The answer is pretty simple:

If the DataRow.Delete method is called, the row transitions such that its RowState is DataRowState.Deleted. (It is only acutally removed from the DataTable when AcceptChanges is called.)

When a row is in DataRowState.Deleted, the normal means for accessing the values do not work (as you have seen).  If all you need to know is that the row is deleted, check the RowState property.  If you need to retrieve the "original", deleted data, you can use an overload of he Item property.  For example, if dr is your row, dr("MyColumnName", DataRowVersion.Original) returns the old value.  (Similarly, dr.IsNull("MyColumnName", DataRowVersion.Original) can be used to check the original data for null).

 

Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Add

About Steve Gray

Steve is a seasoned (translate: old) developer in VB and ASP.NET. He spends most of his time in Dynamics GP, writing custom mods for consulting firms. Crystal reports, eConnect, VS Tools for Dynamics... anything that comes along.