Starts an edit operation on a DataRow object.
Assembly: System.Data (in System.Data.dll)
Use the method to put a DataRow into edit mode. In this mode, events are temporarily suspended, letting the user make changes to more than one row without triggering validation rules. For example, if you must make sure that the value of the column for a total amount is equal to the values for the debit and credit columns in a row, you can put each row into edit mode to suspend the validation of the row values until the user tries to commit the values.
The method is called implicitly when the user changes the value of a data-bound control; the EndEdit method is called implicitly when you invoke the AcceptChanges method for the DataTable object. While in this edit mode, the DataRow stores representations of the original and new proposed values. Therefore, as long as the EndEdit method has not been called, you can retrieve either the original or proposed version by passing either DataRowVersion.Original or DataRowVersion.Proposed for the version parameter of the Item property. You can also cancel any edits at this point by invoking the CancelEdit method.
To see if the row contains an original or proposed value, call the HasVersion method.
The method temporarily suspends RowChanging events, but the delete operation does not.
The example creates a simple DataTable with one DataColumn and five DataRow objects, and a UniqueConstraint. A RowChanged event handler is also added to monitor when the row's value is changing. After invoking on the existing rows, the constraint and event are temporarily disabled and the original and proposed values are printed. The is again invoked to set two rows to the same value. When EndEdit is called, the UniqueConstraint is enforced on the identical values.