This example demonstrates how to handle the grid's RowInserted event to focus the newly inserted row.
After the grid adds a new row to the data source, you can get the row's key value in the grid's server-side RowInserted event. To focus the newly inserted row, call the grid's FindVisibleIndexByKeyValue method to get the row's visible index and assign that index to the grid's FocusedRowIndex property.
protected void grid_RowInserted (object sender, ASPxDataInsertedEventArgs e) {
object newKey = null;
if (e.AffectedRecords == 1) {
ICollection objects = uof.GetObjectsToSave();
if (objects != null && objects.Count == 1) {
IEnumerator enumeration = objects.GetEnumerator();
enumeration.MoveNext();
Customer obj = (Customer)enumeration.Current;
uof.CommitChanges();
newKey = obj.Oid;
}
}
grid.FocusedRowIndex = grid.FindVisibleIndexByKeyValue(newKey);
}
- MyObject.cs (VB: MyObject.vb)
- XpoHelper.cs (VB: XpoHelper.vb)
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx.vb)
(you will be redirected to DevExpress.com to submit your response)