Skip to main content

ASPxClientGridView.UpdateEdit Method

Saves changes and switches the grid to browse mode.

Declaration

UpdateEdit(): void

Remarks

The grid saves changes and switches to browse mode in the following cases:

  • A user clicks the Update comand button.
  • You call the client-side UpdateEdit or the server-side UpdateEdit() method.

The following example demonstrates how to use external button controls to edit the grid’s data records.

View Example: Grid View for ASP.NET Web Forms - How to use external buttons to edit grid data

<table>
    <tr>
        <%--...--%>
        <td>
            <dx:ASPxButton ID="btnSave" runat="server" Text="Save" AutoPostBack="false">
                <ClientSideEvents Click="OnSaveClick" />
            </dx:ASPxButton>
        </td>
        <%--...--%>
    </tr>
    <tr>
        <td colspan="5">
            <dx:ASPxGridView ID="GridView" runat="server" ClientInstanceName="Grid" ...>
                <%--...--%>
                <SettingsBehavior AllowFocusedRow="true" />
            </dx:ASPxGridView>
        </td>
    </tr>
</table>
function OnSaveClick(s, e) {
    Grid.UpdateEdit();
}

Automatically Save Changes After Editing a Cell in Batch Edit Mode

Follow the steps below to allow the grid to automatically save changes in batch edit mode:

  • Handle the client-side BatchEditEndEditing event.
  • In this event handler, set the timeout for the callback function that performs auto saving.
  • Call the batchEditApi.HasChanges method to check if ASPxGridView has unsaved changes.
  • Call the UpdateEdit method to save changes.
<dx:ASPxGridView ID="ASPxGridView1" runat="server" KeyFieldName="CustomerID">
    <%--...--%>
    <SettingsEditing Mode="Batch" />
    <ClientSideEvents BatchEditEndEditing="Grid_BatchEditEndEditing"/>
</dx:ASPxGridView>
function Grid_BatchEditEndEditing(s, e) {
    setTimeout(function () {
        if (s.batchEditApi.HasChanges()) {
            s.UpdateEdit();
        }
    }, 1000);
}
See Also