How to get original DataColumn value from DataRow?

ぃ、小莉子 提交于 2019-12-31 01:56:11

问题


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


回答1:


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.




回答2:


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

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



来源:https://stackoverflow.com/questions/2756965/how-to-get-original-datacolumn-value-from-datarow

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!