Skip to main content

ColumnView.RowUpdated Event

Occurs after changes made to a focused data row have been saved to an underlying data source.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v24.1.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

[DXCategory("Action")]
public event RowObjectEventHandler RowUpdated

Event Data

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

Property Description
Row Gets the processed row.
RowHandle Gets the row’s handle (position). For the ColumnView.RowUpdated event, this property specifies the previous handle (position) of the currently processed row. NewItemRowHandle value when a new row is added. Inherited from RowEventArgs.

Remarks

The RowUpdated event handler is the recommended place to post data to a data storage.

private void gridView1_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e) {
    if (e.RowHandle == GridControl.NewItemRowHandle) {
        // Create a new record.
    } else {
        // Update the corresponding record in a database.
    }
}

The following example shows how to push row edits to an Entity Framework source.

DXApplication.AdventureWorksDW2008R2Entities dbContext;

private void gridView1_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e) {
    dbContext.SaveChanges();
}

This event fires only after the edited row has lost focus, i.e after a user has selected another row or clicked anywhere outside the View. The following example calls the the ColumnView.UpdateCurrentRow method to manually trigger the RowUpdated event as soon as a column CalcEdit in-place editor closes.

private void repositoryItemCalcEdit1_EditValueChanged(object sender, EventArgs e) {
    gridView1.PostEditor(); //save the cell value to a data source
    gridView1.UpdateCurrentRow(); //update the row and raise the RowUpdated event
}

Do not assign a new data source in the event handler. Use the Row parameter to obtain the data row.

private void GridView1_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e) {
    DataRowView rowView = e.Row as DataRowView;
    DataRow row = rowView.Row;
}

To validate cell values before they are saved to a data source, handle the ColumnView.ValidateRow event.

Note

By default, if an exception is raised within a RowUpdated event handler, it is silently swallowed by the grid control. To prevent exceptions from being caught internally by the grid control, you can set the static DevExpress.Data.DataControllerBase.CatchRowUpdatedExceptions property to false on the application startup.

See Also