Skip to main content

ASPxGridView.FocusedRowIndex Property

Gets or sets the focused row by its index.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v22.1.dll


public int FocusedRowIndex { get; set; }

Property Value

Type Description

An integer value that specifies the focused row’s index.


Rows within a Grid View are identified by their indexes. The FocusedRowIndex property identifies the currently focused row. Setting this property to a new value moves focus to the corresponding row displayed within the current page.

If the row isn’t displayed within the current page, you should switch to the required page and then move row focus (see an example below).

When row focus changes, the ASPxGridView.FocusedRowChanged event is raised.

The focused row feature is enabled when the ASPxGridViewBehaviorSettings.AllowFocusedRow property is set to true. Otherwise, the FocusedRowIndex property’s value is set to -1. In this instance, the row currently being edited is identified by the ASPxGridView.EditingRowVisibleIndex property.


The following example illustrates how to use the FocusedRowIndex property.

Web Forms approach:

protected void gridView_FocusedRowChanged(object sender, EventArgs e) {
    ASPxGridView grid = sender as ASPxGridView;
    Response.Cookies[grid.ID]["FocusedIndex"] = grid.FocusedRowIndex.ToString();
    Response.Cookies[grid.ID].Expires = DateTime.Now.AddDays(1d);
protected void gridView_DataBound(object sender, EventArgs e) {
    ASPxGridView grid = sender as ASPxGridView;
    if (Request.Cookies[grid.ID] != null)
        grid.FocusedRowIndex =Convert.ToInt32(Request.Cookies[grid.ID]["FocusedIndex"]);

MVC approach:

@Html.DevExpress().GridView(settings => {
    settings.Name = "GridView";
    settings.CallbackRouteValues = new { Controller = "Home", Action = "GridViewPartial" };
    settings.SettingsPager.PageSize = 5;

    settings.KeyFieldName = "EmployeeID";

    settings.PreRender = (s, e) => {
        var sender = (MVCxGridView)s;
        // Set the zero-based index of the focused row.  
        sender.FocusedRowIndex = 6;
    // Enable row focus.  
    settings.SettingsBehavior.AllowFocusedRow = true;

Online Examples

See Also