Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataRow.EndEdit Method

Ends the edit occurring on the row.

[Visual Basic]
Public Sub EndEdit()
[C#]
public void EndEdit();
[C++]
public: void EndEdit();
[JScript]
public function EndEdit();

Exceptions

Exception Type Condition
InRowChangingEventException The method was called inside the RowChanging event.
ConstraintException The edit broke a constraint.
ReadOnlyException The row belongs to the table and the edit tried to change the value of a read-only column.
NoNullAllowedException The edit tried to put a null value into a column where AllowDBNull is false.

Remarks

When setting the property, an exception is generated if an exception occurs in the RowChanging event.

Example

[Visual Basic, C#, C++] The following example edits the value of one column in the last row of a DataGrid control. The example uses the BeginEdit, EndEdit, methods to edit the column's value and commit the change to the row.

[Visual Basic] 
Private Sub AcceptOrReject(ByVal myRow As DataRow)
   ' Use a function to validate the row's values.
   ' If the function returns true, end the edit; otherwise cancel it.
   If ValidateRow(myRow) Then
      myRow.EndEdit()
   Else
      myRow.CancelEdit()
   End If
End Sub

Private Function ValidateRow(ByVal myRow As DataRow) As Boolean
   Dim isValid As Boolean
   ' Insert code to validate the row values. Set the isValid variable.
   ValidateRow = isValid
End Function

[C#] 
private void AcceptOrReject(DataRow myRow){
   // Use a function to validate the row's values.
   // If the function returns true, end the edit; otherwise cancel it.
   if(ValidateRow(myRow))
      myRow.EndEdit();
   else
      myRow.CancelEdit();
}

private bool ValidateRow(DataRow thisRow){
   bool isValid = true; 
   // Insert code to validate the row values. Set the isValid variable.
   return isValid;
}

[C++] 
private:
 void AcceptOrReject(DataRow* myRow){
    // Use a function to validate the row's values.
    // If the function returns true, end the edit; otherwise cancel it.
    if(ValidateRow(myRow))
       myRow->EndEdit();
    else
       myRow->CancelEdit();
 }
 
 bool ValidateRow(DataRow* thisRow){
    bool isValid = true; 
    // Insert code to validate the row values. Set the isValid variable.
    return isValid;
 }

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

Requirements

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 | AllowDBNull | BeginEdit | CancelEdit | HasVersion | Item | RowState

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft