asp.net.ph

DataRow.HasVersion Method

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

Parameters

version
One of the DataRowVersion values.

Return Value

This method returns only a boolean value: true if the version exists; otherwise, false.

The property is read only with no default value.

Remarks

See the BeginEdit method for more details.

Example

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
   
See Also

DataRow Members   AcceptChanges   BeginEdit   CancelEdit   Item   GetChildRows   GetParentRows   EndEdit   RowState Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph