NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DataRow.HasVersion

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;

Parameters

version
One of the DataRowVersion values that specifies the row version. Possible values are Default, Original, Current, and Proposed.

Return Value

true if the version exists; otherwise, false.

Remarks

See the BeginEdit method for more details.

Example [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 = 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

See Also

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