Gets a value indicating whether a specified version exists.
[Visual Basic] Public Function HasVersion( _ ByVal version As DataRowVersion _ ) As Boolean [C#] public bool HasVersion( DataRowVersion version ); [C++] public: bool HasVersion( DataRowVersion version ); [JScript] public function HasVersion( version : DataRowVersion ) : Boolean;
true if the version exists; otherwise, false.
See the BeginEdit method for more details.
The following example uses the HasVersion method to determine if the current value of a column and the proposed value are the same. If so, the edit is cancelled. Otherwise, the AcceptChanges method is called to end the edit.
[Visual Basic]
Private Sub CheckVersionBeforeAccept() Dim r As DataRow Dim t As DataTable ' Assuming the DataGrid is bound to a DataTable. t = DataGrid1.DataSource r = t.Rows(DataGrid1.CurrentCell.RowNumber) r.BeginEdit r(1) = Edit1.Text If r.HasVersion(datarowversion.Proposed) Then If r(1, DataRowVersion.Current) = r(1, DataRowversion.Proposed) Then MessageBox.Show "The original and the proposed are the same" r.CancelEdit Exit Sub Else r.AcceptChanges End If Else MessageBox.Show "No new values proposed" End If End Sub
DataRow Class | DataRow Members | System.Data Namespace | AcceptChanges | BeginEdit | CancelEdit | Item | GetChildRows | GetParentRows | EndEdit | RowState