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.v20.1.dll

Declaration

[DXCategory("Action")]
public event RowObjectEventHandler RowUpdated
<DXCategory("Action")>
Public Event RowUpdated As RowObjectEventHandler

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. Inherited from RowEventArgs.

Remarks

The RowUpdated event handler is the recommended place to post data to a data storage. The code below illustrates 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 use the RowHandle event parameter to identify the edited row: RowHandle stores the handle this row had before row edits were saved. Instead, use the Row parameter.

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