ASPxGridView.Selection Property
Gets the ASPxGridView’s selection.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v20.1.dll
NuGet Package: DevExpress.Web
Declaration
Property Value
Type | Description |
---|---|
GridViewSelection | A GridViewSelection object that represents the ASPxGridView’s selection. |
Remarks
The ASPxGridView allows multiple rows to be selected. The object returned by the Selection property provides methods that allow you to select and deselect individual rows, or all rows, obtain the number of selected rows, etc. End-users can select/deselect rows via the Select Command Column Item, which is represented by a check box or radio button (based on the ASPxGridViewBehaviorSettings.AllowSelectSingleRowOnly property value):
The style settings used to paint selected rows can be accessed via the GridViewStyles.SelectedRow property.
To respond to changing selection, handle the ASPxGridBase.SelectionChanged event.
Note
The Selection property is not in effect if cell merging is enabled.
Example
This example demonstrates how to select customers who live in the specified country.
An end-user types the country into the search box and clicks Search. The button editor’s ButtonClick event is handled to call the ASPxClientGridView.PerformCallback method.
This sends a callback to the server and generates the ASPxGridView.CustomCallback event passing it the country entered by the user. The CustomCallback event is handled to select the customers who live in the specified country.
protected void grid_CustomCallback(object sender, 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);
}