ASPxGridBase.FindVisibleIndexByKeyValue(Object) Method

Returns the data item (row, card or record) visible index by its key value.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v21.1.dll


public int FindVisibleIndexByKeyValue(
    object keyValue


Name Type Description
keyValue Object

An object that uniquely identifies the row.


Type Description

An integer value that specifies the data item visible index. The ASPxGridView.InvalidRowIndex value if the row is not found.


The FindVisibleIndexByKeyValue method searches for the specified data item (row, card or record) in all the data items displayed within the grid. If the data item is not found, the FindVisibleIndexByKeyValue method returns the ASPxGridView.InvalidRowIndex field value.


This example shows how to focus a row that is not displayed within the current page. To do this, switch to the page that contains the required row, and then move row focus.

using DevExpress.Web.ASPxGridView;


protected void Button1_Click(object sender, EventArgs e) {
    // Obtain the visible index of the required row.
    int rowIndex = grid.FindVisibleIndexByKeyValue("OLDWO");
    if (rowIndex == ASPxGridView.InvalidRowIndex) return;
    if (!IsRowVisibleOnScreen(rowIndex)) {
        // Switch to the page that contains the required row.
    // Focus the required row.
    grid.FocusedRowIndex = rowIndex;
bool IsRowVisibleOnScreen(int rowIndex) {
    int startIndex = grid.PageIndex * grid.SettingsPager.PageSize;
    int endIndex = startIndex + grid.SettingsPager.PageSize;
    return rowIndex >= startIndex && rowIndex < endIndex;
void GoToPage(int rowIndex) {
    grid.PageIndex = rowIndex / grid.SettingsPager.PageSize;