Rejects all changes made to the row since AcceptChanges was last called.
[Visual Basic] Public Sub RejectChanges() [C#] public void RejectChanges(); [C++] public: void RejectChanges(); [JScript] public function RejectChanges();
Exception Type | Condition |
---|---|
RowNotInTableException | The row doesn't belong to the table. |
When calling the RejectChanges method, the CancelEdit method is implicitly called to cancel any edits. If RowState is Deleted or Modified, the row reverts to its previous values, and RowState becomes Unchanged. If the RowState is New, the row is removed.
The following example uses the IsNull method to check if a column is set to a null value. If so, the RejectChanges method is called.
[Visual Basic]
Private Sub IsValNull() Dim t As DataTable ' Assuming the DataGrid is bound to a DataTable. t = DataGrid1.DataSource Dim r As DataRow r = t.Rows(datagrid1.CurrentCell.RowNumber) r.BeginEdit r(1) = Null r.EndEdit If r.IsNull(1) Then r.RejectChanges r.AcceptChanges Else r.AcceptChanges End If End Sub
DataRow Class | DataRow Members | System.Data Namespace | AcceptChanges | IsNull