Kettic ASP.NET Ajax GridView provides users of GridView Control the selection functionality to select one or more rows or cells from the shown data items. This selection features support multiple selection functionality and rows and cells selection in C# code. For example, the asp.net GridView component supports a single row selection, multiple rows selection, a single cell selection, as well as multiple cells selection. Web UI designers can easily customize the GridView selection manually.
How to Select Grid Row in C#
To select rows from asp.net data grid view, we need enable the selection feature to DataGrid. Select row in gridview, it means the whole row line will be selected. The default selection setting of Kettic web GridView allows users select one row from the data grid. The C# code below demonstrates the default setting of this property.
How to Select Grid Cell in C#
To select cells from asp.net data grid, we can change the value of the SelectMode property to SelectCell from the GridViewSelectMode enumeration. Select cell in gridview, it means only one cell in the row will be selected. The C# example code below shows how to achieve this.
How to Select Multiple Rows in C#
To perform the multiple rows selection, we need enable the MultipleSelect property first, and then set the SelectMode to GridViewSelectMode.SelectFullRows. The C# sample code below shows how to achieve this.
Click to Select a Row
Set ClientSettings.Selecting.AllowRowSelect property is True, users can select a single data row by clicking current row. And users can change the style while the row is selected.
If you want to select multiple rows, you need to set AllowMultiRowSelection property to True. There are two ways to select multiple rows in the asp.net data gridview.
The one is using Ctrl. When multi-row selection is enabled, pressing the Ctrl key down, you can click the wanted rows, and these rows will be selected after your click. What's more, the multiple selected rows can be in a discontiguous IDs.
The other is using Shift key. Pressing the Shift key down, the selected rows will be the rows between the two clicks. So that in this way, the selected rows must be continuous.
Selecting Rows with CheckBoxes
Another way is adding checkbox to select grid rows.
Here, you can add checkbox into two areas.
One is in HeaderItemTemplate, the checkbox will appear in the column header. Specify the OnCheckChanged event, so that when the checkbox is selected, all the rows in the asp.net grid is selected.
The other is in ItemTemplate, the checkbox will appear in each rows. Specify the OnCheckChanged event, so that when the checkbox is selected, the current row line in the grid will be selected.
Selecting Rows with Select Button
Be similar with selecting rows by checkbox, users can insert button into the asp.net gridview control to do the selection. There will be two button appear in each row, "select" and "unselect". Using "select" to select current row in web gridview, and using "unselect" to cancel the select before.
You can set GridButtonColumn with select and deselect commands to select grid rows.
ASP.NET AJAX UI Controls