Testing the Row Version by calling the Has Version method and passing a Data RowVersion as an argument

illegal for non-trainer use

Introduction

Testing the row version

The DataRow class includes the RowState property, whose values indicate whether and how the row has changed since the DataTable was first created or loaded from the database. (RowState property values include Deleted, Modified, New, and Unchanged.)

Changes made to column values in a DataRow are immediately placed in the Current state of the row. At this point the RowState is set to Modified.

When modifying column values in a DataRow directly, the DataRow manages column values by using the following row versions: Current, Default, and Original. The BeginEdit, EndEdit, and CancelEdit methods utilize a fourth row version: Proposed.

You can test whether a DataRow has a particular row version by calling the HasVersion method and passing a DataRowVersion as an argument. For example, DataRow.HasVersion(DataRowVersion.Original) will return false for newly added rows.

The Proposed row version exists during an edit operation that is begun by calling BeginEdit and ended with either EndEdit or CancelEdit. During the edit operation, you can apply validation logic to individual columns by evaluating the ProposedValue in the ColumnChanged event of the DataTable. The DataColumnChangeEventArgs value passed to the ColumnChanged event contains a reference to the changing column and the ProposedValue. You can modify the proposed value or trigger the edit to be canceled. The row moves out of the proposed state when the edit is completed.

0 0

Post a comment