Skip to main content
Tab

ASPxGridView.RowUpdating Event

Enables you to prevent a row from being updated.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.2.dll

Declaration

public event ASPxDataUpdatingEventHandler RowUpdating

Event Data

The RowUpdating event's data class is ASPxDataUpdatingEventArgs. The following properties provide information specific to this event:

Property Description
Cancel Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.
Keys Gets a dictionary of field name/value pairs that represent the primary key of the row to update.
NewValues Gets a dictionary that contains the values of the non-key field name/value pairs in the row to be updated.
OldValues Gets a dictionary that contains the original field name/value pairs in the row to be updated.

Remarks

The RowUpdating event occurs when a user has changed cell values and tries to pass them to the data source by clicking the Update command. To cancel the update operation, set the Cancel argument property to true.

If you use edit form templates, you should process the update manually in the RowUpdating event handler.

After a row has been updated, the RowUpdated event is raised.

Example

This example demonstrates how to use ASPxGridView to edit an in-memory data set with a master-detail relationship.

View Example: How to edit an in-memory data set with a master-detail relationship

To enable this behavior, follow the steps below:

  1. Handle the RowUpdating, RowInserting, and RowDeleting events and update the data source manually.

  2. Set the cancel argument property to true and call the grid’s CancelEdit() method.

<dx:ASPxGridView ID="MasterGridView" runat="server" AutoGenerateColumns="False" SettingsPager-PageSize="3"
    KeyFieldName="ID" OnRowUpdating="MasterGridView_RowUpdating" Width="588px" OnRowDeleting="MasterGridView_RowDeleting" OnRowInserting="MasterGridView_RowInserting">
    <!-- ... -->
    <SettingsDetail ShowDetailRow="True" />
    <Templates>
        <DetailRow>
            <dx:ASPxGridView ID="DetailGridView" runat="server" AutoGenerateColumns="False" SettingsPager-PageSize="4"
                KeyFieldName="ID" OnBeforePerformDataSelect="DetailGridView_BeforePerformDataSelect"
                OnRowUpdating="MasterGridView_RowUpdating" Width="100%">
                <!-- ... -->
            </dx:ASPxGridView>
        </DetailRow>
    </Templates>
</dx:ASPxGridView>
protected void MasterGridView_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) {
    ds = (DataSet)Session["DataSet"];
    ASPxGridView gridView = (ASPxGridView)sender;
    DataTable dataTable = gridView.GetMasterRowKeyValue() != null ? ds.Tables[1] : ds.Tables[0];
    DataRow row = dataTable.Rows.Find(e.Keys[0]);
    IDictionaryEnumerator enumerator = e.NewValues.GetEnumerator();
    enumerator.Reset();
    while (enumerator.MoveNext())
        row[enumerator.Key.ToString()] = enumerator.Value;
    gridView.CancelEdit();
    e.Cancel = true;
}

Online Examples

View Example: Implement the Select All check box for a templated column in batch edit mode

View Example: How to use the Rich Text Editor to edit formatted text in the Edit Form

View Example: How to upload files and save them to a binary column in edit mode

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the RowUpdating event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also