This documentation is archived and is not being maintained.

DataRow.HasVersion Method

Gets a value indicating whether a specified version exists.

[Visual Basic]
Public Function HasVersion( _
   ByVal version As DataRowVersion _
) As Boolean
public bool HasVersion(
 DataRowVersion version
public: bool HasVersion(
 DataRowVersion version
public function HasVersion(
   version : DataRowVersion
) : Boolean;


One of the DataRowVersion values that specifies the row version.

Return Value

true if the version exists; otherwise, false.


See the BeginEdit method for more details.


[Visual Basic] 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 = CType(DataGrid1.DataSource, DataTable)
    r = t.Rows(DataGrid1.CurrentCell.RowNumber)
    r(1) = Edit1.Text
    If r.HasVersion(datarowversion.Proposed) Then
       If r(1, DataRowVersion.Current) Is r(1, DataRowversion.Proposed) Then
          MessageBox.Show("The original and the proposed are the same")
          Exit Sub
       End If
       MessageBox.Show("No new values proposed")
    End If
 End Sub

[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataRow Class | DataRow Members | System.Data Namespace | AcceptChanges | BeginEdit | CancelEdit | Item | GetChildRows | GetParentRows | EndEdit | RowState