ASPxGridView.Selection Property
Gets an object that allows you to access row selection methods.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.2.dll
Declaration
Property Value
Type | Description |
---|---|
GridViewSelection | An object that contains row selection methods. |
Remarks
The Selection
property returns the GridViewSelection object. It contains methods that allow you to select or deselect data rows, and get information about the current row selection state.
When the row selection changes, the control raises the client-side ClientGridView.SelectionChanged or the server-side ASPxGridBase.SelectionChanged event (based on the ProcessSelectionChangedOnServer property value).
For more information on row selection in the grid, refer to the following topic: Selection.
<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="Invert 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