Nikhil Vaghela
Nikhil Vaghela

Reputation: 930

How to get original DataColumn value from DataRow?

I have a DataTable and i want to figure out the Original column value for all the modified data rows.

I am using following approach to get the Orginal column value before the DataRow was modified

DataRow[] dataRowArray = dataTableInstance.Select(null,null,DataViewRowState.OriginalRows);
DataRow originalDataRow = dataRowArray[rowIndex][columnIndex, DataRowVersion.Original] 

Please point out what am I doing wrong here ? Above code does not give me the Original column , instead it gives me the latest modified column value.

Thanks.
Nikhil

Upvotes: 3

Views: 14117

Answers (2)

Ben
Ben

Reputation: 6227

DataRow row = undefinedrow;   
row["Column"].ToString(); 

this returns the value converted to a String of the Column devined.

Upvotes: 0

Thomas Levesque
Thomas Levesque

Reputation: 292605

Original values are lost when you call AcceptChanges (which is usually called when you call Update on a DataAdapter or TableAdapter too). Once the changes are accepted, you can't access the original values, that's probably why your code doesn't work.

Upvotes: 3

Related Questions