Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[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
    [Collapse]Focus and Navigation
      Focused Row
      Selection
     [Expand]Paging and Scrolling
      Keyboard Navigation
    [Expand]Data Editing and Validation
    [Expand]Export Overview
   [Expand]Visual Elements
   [Expand]Examples
  [Expand]Card View
  [Expand]Vertical Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]HTML Editor
  [Expand]Image and Data Browsing
  [Expand]Docking and Popups
  [Expand]Navigation and Layout Extensions
  [Expand]File Management
  [Expand]Multi-Use Site Extensions
  [Expand]Charts
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Tree List
  [Expand]Data Editor Extensions
  [Expand]Report Extensions
  [Expand]SpellChecker
 [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]Document Server
[Expand]Reporting
[Expand]Report 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 the client and server sides.

Expanded Selection Overview

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

If the ASPxGridViewBehaviorSettings.AllowSelectByRowClick (via GridViewSettings.SettingsBehavior.AllowSelectByRowClick) option 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.

GridView supports single and multiple row selection modes. To switch to single row selection mode, set the ASPxGridViewBehaviorSettings.AllowSelectSingleRowOnly (via GridViewSettings.SettingsBehavior.AllowSelectSingleRowOnly) property value 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 (via GridViewSettings.Styles.SelectedRow) property.

Expanded Processing Selected Rows on the Client Side

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

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

Example

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

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, you should get the selected rows on the client-side and then send them to the server via a callback.

Example

In this example, the ASPxClientGridView.SelectionChanged (via MVCxClientGridView.SelectionChanged) client-side event is handled to get a collection of selected values and send them to the server side via a callback. Contact names and cities are obtained using the ASPxClientGridView.GetSelectedFieldValues (via MVCxClientGridView.GetSelectedFieldValues ) function, 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:

How would you rate this topic?​​​​​​​