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?
The answer set doesn't match your query, it will include 'C' rows, too. ROWS between UNBOUNDED PRECEDING and CURRENT ROW is a group sum. You need ROWS between 1 PRECEDING and 1 PRECEDNG and an ORDER BY to get the previous row's value.
Table 1 shows that our exemplifying data.table consists of five rows and five columns. This example explains how to get the values from one row before when doing calculations with a data.table.
ROWS between UNBOUNDED PRECEDING and CURRENT ROW is a group sum. You need ROWS between 1 PRECEDING and 1 PRECEDNG and an ORDER BY to get the previous row's value. Better switch to LAG or LAST_VALUE, which is simpler and allows dealing with additional rows between the 'A15' and the previous 'C' row:
Better switch to LAG or LAST_VALUE, which is simpler and allows dealing with additional rows between the 'A15' and the previous 'C' row:
You should subscribe to the ColumnChanged
event, that way you can see the previous and current values.
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]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With