[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]ASP.NET WebForms Controls
 [Collapse]ASP.NET MVC Extensions
  [Expand]Product Information
  [Expand]Getting Started
  [Expand]Common Concepts
  [Collapse]Grid View
    Overview - GridView
    Main Features - GridView
   [Collapse]Concepts
    [Expand]Binding to Data
    [Expand]Data Representation Basics
    [Expand]Data Shaping and Manipulation
    [Collapse]Focus and Navigation
      Focused Row
      Selection
     [Expand]Paging and Scrolling
      Keyboard Navigation
    [Expand]Data Editing and Validation
    [Expand]Exporting
   [Expand]Visual Elements
   [Expand]Member Tables
   [Expand]Examples
  [Expand]Tree List
  [Expand]Card View
  [Expand]Reporting
  [Expand]Charting
  [Expand]Pivot Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Scheduler
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors Extensions
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Extensions
  [Expand]SpellChecker
  [Expand]Query Builder
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Selection

This topic describes the concept of row selection, including an overview of the selection functionality, as well as how to process selected records on client and server sides.

Expanded Selection Overview

The GridView allows end-users to select rows using the following methods.

If the ASPxGridViewBehaviorSettings.AllowSelectByRowClick option (using GridViewSettings.SettingsBehavior.AllowSelectByRowClick) is enabled, end-users can change the selection by clicking rows in combination with the SHIFT or CTRL key. In multiple row selection mode, clicking a row while holding down the CTRL key toggles the row's selected state. Contiguous rows can be selected by clicking the first row and the last row while holding down the SHIFT key. After this, the selection can be further customized by clicking individual rows while holding down the CTRL key.

The GridView supports single and multiple row selection modes. To switch to single row selection mode, set the ASPxGridViewBehaviorSettings.AllowSelectSingleRowOnly property value (using GridViewSettings.SettingsBehavior.AllowSelectSingleRowOnly) to true. In single row selection mode, the command column cells display radio buttons instead of check boxes.

The style settings used to paint selected rows can be accessed and customized using the GridViewStyles.SelectedRow property (using GridViewSettings.Styles.SelectedRow).

Expanded Processing Selected Rows on the Client Side

The GridView provides a full-featured client-side API that allows you to select and deselect rows using JS code. The table below lists the available selection-related methods.

Method Description
ASPxClientGridView.GetSelectedFieldValues (using MVCxClientGridView.GetSelectedFieldValues) Returns the row values displayed within all selected rows.
ASPxClientGridView.GetSelectedKeysOnPage (using MVCxClientGridView.GetSelectedKeysOnPage) Returns key values of selected rows displayed within the current page.
ASPxClientGridView.GetSelectedRowCount (using MVCxClientGridView.GetSelectedRowCount) Returns the number of selected rows.
ASPxClientGridView.IsRowSelectedOnPage (using MVCxClientGridView.IsRowSelectedOnPage) Indicates whether or not the specified row is selected within the current page.
ASPxClientGridView.SelectAllRowsOnPage (using MVCxClientGridView.SelectAllRowsOnPage) Allows you to select or deselect all rows displayed on the current page based on the parameter passed.
ASPxClientGridView.SelectRowOnPage (using MVCxClientGridView.SelectRowOnPage) Selects or deselects the specified row displayed on the current page.
ASPxClientGridView.SelectRows (using MVCxClientGridView.SelectRows) Selects all the unselected rows within the grid.
ASPxClientGridView.SelectRowsByKey (using MVCxClientGridView.SelectRowsByKey) Selects a grid row by its key.
ASPxClientGridView.UnselectAllRowsOnPage (using MVCxClientGridView.UnselectAllRowsOnPage) Deselects all selected rows displayed on the current page.
ASPxClientGridView.UnselectFilteredRows (using MVCxClientGridView.UnselectFilteredRows) Deselects all grid rows that match the filter criteria currently applied to the grid.
ASPxClientGridView.UnselectRowOnPage (using MVCxClientGridView.UnselectRowOnPage) Deselects the specified row (if selected) displayed on the current page.
ASPxClientGridView.UnselectRows (using MVCxClientGridView.UnselectRows) Deselects the specified row (if selected) within the grid.
ASPxClientGridView.UnselectRowsByKey (using MVCxClientGridView.UnselectRowsByKey) Deselects the specified row displayed within the grid.

Example

In this example, the ASPxClientGridView.SelectionChanged client-side event (using MVCxClientGridView.SelectionChanged) is handled to display selected contacts within a list box. Contact names are obtained using the ASPxClientGridView.GetSelectedFieldValues function (using MVCxClientGridView.GetSelectedFieldValues ).

View code:

Partial View code:

The image below illustrates the result.

Expanded Processing Selected Rows on the Server Side

To obtain the selected rows on the server side, get the selected rows on the client-side and then send them to the server using a callback.

Example

In this example, the ASPxClientGridView.SelectionChanged client-side event (using MVCxClientGridView.SelectionChanged) is handled to get a collection of selected values and send them to the server side with a callback. Contact names and cities are obtained using the ASPxClientGridView.GetSelectedFieldValues function (using MVCxClientGridView.GetSelectedFieldValues ), and are passed to the OnGetValues function. The OnGetValues function concatenates the selected values to a single string and sends the resulting string to the server using the MVCxClientGridView.PerformCallback method. In the controller code, you can split the string into separate values.

View code:

Partial View code:

Controller code:

Is this topic helpful?​​​​​​​