Skip to main content

GridViewSelection.IsRowSelected(Int32) Method

Indicates whether the specified row is selected.

Namespace: DevExpress.Web.Data

Assembly: DevExpress.Web.v22.1.dll

Declaration

public bool IsRowSelected(
    int visibleIndex
)

Parameters

Name Type Description
visibleIndex Int32

The row’s visible index.

Returns

Type Description
Boolean

true if the specified row is selected; otherwise, false.

Remarks

For more information on row selection in the grid, refer to the following topic: Selection.

The code sample below gets the current selection state of the row with the specified visible index and changes it.

<dx:ASPxGridView ID="gridview" ClientInstanceName="grid" runat="server" AutoGenerateColumns="False"
    KeyFieldName="ProductID" OnCustomCallback="gridview_CustomCallback">
    <Columns>
        <dx:GridViewCommandColumn ShowSelectCheckbox="true" VisibleIndex="0" />
        <%--...--%>
    </Columns>
</dx:ASPxGridView>
<br />
<dx:ASPxButton ID="ASPxButton1" runat="server" Text="Change selection state" AutoPostBack="false">
    <ClientSideEvents Click="onButtonClick" />
</dx:ASPxButton>
function onButtonClick(s, e) {
    grid.PerformCallback();
}
protected void gridview_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) {
    var grid = sender as ASPxGridView;
    var visibleIndex = 0;
    if(grid.Selection.IsRowSelected(visibleIndex)) {
        grid.Selection.UnselectRow(visibleIndex);
    } else {
        grid.Selection.SelectRow(visibleIndex);
    }
}
See Also