Skip to main content

How to: Select Rows That Contain the Specified Value

This example demonstrates how to select customers who live in the specified country.

When a user types a country name into the search box and clicks the Find button, the button’s ButtonClick event handler calls the ASPxClientGridView.PerformCallback method.

The PerformCallback method sends a callback to the server and raises the ASPxGridView.CustomCallback event. This event obtains the country that the user enters.

exGetValuesOnCustomCallback

<dx:ASPxButtonEdit ID="ButtonEdit" runat="server" ...>
    <!-- ... -->
    <ClientSideEvents ButtonClick="OnButtonClick" />
</dx:ASPxButtonEdit>
<br />
<dx:ASPxGridView ID="Grid" runat="server" ClientInstanceName="ClientGrid"
    OnCustomCallback="Grid_CustomCallback" ...>
    <Columns>
        <!-- ... -->
        <dx:GridViewDataTextColumn FieldName="Country"/>
    </Columns>
</dx:ASPxGridView>
function OnButtonClick(s, e) {
    var text = s.GetText();
    ClientGrid.PerformCallback(text);
}
protected void Grid_CustomCallback(object sender, DevExpress.Web.ASPxGridViewCustomCallbackEventArgs e) {
    string country = e.Parameters.ToString();
    Grid.Selection.UnselectAll();
    for(int i = 0; i < Grid.VisibleRowCount; i++)
        if(Grid.GetRowValues(i, "Country") != null)
            if(Grid.GetRowValues(i, "Country").ToString() == country)
                Grid.Selection.SelectRow(i);
}