Skip to content

DevExpress-Examples/asp-net-web-forms-grid-focus-inserted-row

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grid View for ASP.NET Web Forms - How to focus the newly inserted row

This example demonstrates how to handle the grid's RowInserted event to focus the newly inserted row.

Overview

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);
}

Files to Review

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Handle the grid's RowInserted event to focus the newly inserted row.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •