asp.net.ph

DataRowView.BeginEdit Method

System.Data Namespace   DataRowView Class


Begins an edit procedure.

[ VB ]
NotOverridable Public Sub BeginEdit ( )

[ C# ]
public void BeginEdit ( );

[ C++ ]
public: __sealed void BeginEdit ( );

[ JScript ]
public function BeginEdit ( );

Remarks

The BeginEdit method is identical to the DataRow.BeginEdit method of the DataRow. After calling BeginEdit, any changes made to the DataRowView can be rolled back by calling CancelEdit. Call the BeginEdit method before allowing users to change row values. After values have been changed, you retrieve the new values by setting the RowVersion to DataRowVersion.Proposed. Check the values with a business rule, and roll back the changes if needed by calling CancelEdit, or call EndEdit to accept the changes.

Example

The following example edits a row in a DataRowView, calling the BeginEdit before, and EndEdit afterwards.

private void EditDataRowView ( DataRowView drv, string colToEdit ) {
   drv.BeginEdit ( );
   drv [ colToEdit ] = textBox1.Text;
   // validate the input with a function.
   if ( ValidateCompanyName ( drv [ colToEdit ] ) )
      drv.EndEdit ( );
   else
      drv.CancelEdit ( );

}

private bool ValidateCompanyName ( object valuetoCheck ) {
   // insert code to validate the value.
   return true;
}
  C# VB

See Also

DataRowView Members   AcceptChanges   AllowDelete   AllowEdit   AllowNew   CancelEdit   DataRow   EndEdit 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