aspnet-3748-components-grid-view-examples-how-to-select-rows-that-contain-the-specified-value.md
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.
<dx:ASPxButtonEdit ID="ButtonEdit" runat="server" ...>
<!-- ... -->
<ClientSideEvents ButtonClick="OnButtonClick" />
</dx:ASPxButtonEdit>
<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);
}
Protected Sub Grid_CustomCallback(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxGridViewCustomCallbackEventArgs)
Dim country As String = e.Parameters.ToString()
Grid.Selection.UnselectAll()
For i As Integer = 0 To Grid.VisibleRowCount - 1
If Grid.GetRowValues(i, "Country") IsNot Nothing Then
If Grid.GetRowValues(i, "Country").ToString() = country Then Grid.Selection.SelectRow(i)
End If
Next
End Sub