System.Data Namespace DataRow Class
Checks whether a specified version exists.
[ VB ]
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
- version
- One of the DataRowVersion values.
This method returns only a boolean value: true if the version exists; otherwise, false.
The property is read only with no default value.
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.
Private Sub CheckVersionBeforeAccept ( )
Dim row As DataRow
Dim tbl As DataTable
' assuming the DataGrid is bound to a DataTable.
tbl = myGrid.DataSource
row = tbl.Rows ( myGrid.CurrentCell.RowNumber )
row.BeginEdit
row ( 1 ) = Edit1.Text
If row.HasVersion ( datarowversion.Proposed ) Then
If row ( 1, DataRowVersion.Current ) = row ( 1, DataRowversion.Proposed ) Then
Response.Write "the original and the proposed are the same"
row.CancelEdit
Exit Sub
Else
row.AcceptChanges
End If
Else
Response.Write "No new values proposed"
End If
End Sub
DataRow Members AcceptChanges BeginEdit CancelEdit Item GetChildRows GetParentRows EndEdit RowState