I have a DataTable. When change in row happens I need to get this row and it's previous value(DataRow). How can I get it?
我有一个数据表。当行中发生变更时,我需要获取这一行,它是先前的值(DataRow)。我怎么得到它?
1 个解决方案
#1
8
You should subscribe to the ColumnChanged
event, that way you can see the previous and current values.
您应该订阅ColumnChanged事件,这样就可以看到以前和当前的值。
Example:
例子:
//code to wire up the handler
custTable.ColumnChanged += new DataColumnChangeEventHandler(Column_Changed);
//code for the event
private static void Column_Changed(object sender, DataColumnChangeEventArgs e )
{
Console.WriteLine("Column_Changed Event: name={0}; Column={1}; original name={2}",
e.Row["name"], e.Column.ColumnName, e.Row["name", DataRowVersion.Original]);
}
#1
8
You should subscribe to the ColumnChanged
event, that way you can see the previous and current values.
您应该订阅ColumnChanged事件,这样就可以看到以前和当前的值。
Example:
例子:
//code to wire up the handler
custTable.ColumnChanged += new DataColumnChangeEventHandler(Column_Changed);
//code for the event
private static void Column_Changed(object sender, DataColumnChangeEventArgs e )
{
Console.WriteLine("Column_Changed Event: name={0}; Column={1}; original name={2}",
e.Row["name"], e.Column.ColumnName, e.Row["name", DataRowVersion.Original]);
}