GridView.AutoGenerateSelectButton Property
Assembly: System.Web (in system.web.dll)
public: virtual property bool AutoGenerateSelectButton { bool get (); void set (bool value); }
/** @property */ public boolean get_AutoGenerateSelectButton () /** @property */ public void set_AutoGenerateSelectButton (boolean value)
public function get AutoGenerateSelectButton () : boolean public function set AutoGenerateSelectButton (value : boolean)
Not applicable.
Property Value
true to automatically add a CommandField field column with a Select button for each data row; otherwise, false. The default is false.When the AutoGenerateSelectButton property is set to true, a column (represented by a CommandField object) with a Select button for each data row is automatically added to the GridView control. Clicking the Select button for a row selects that row in the control, which sets the SelectedIndex property to the index of the row. To retrieve the GridViewRow object that represents the selected row, use the SelectedRow property. You can also get the primary key value for the selected record by using the SelectedValue property. The SelectedValue property contains the values of the key fields specified in the DataKeyNames property.
Note: |
|---|
| You can programmatically select a row by setting the SelectedIndex property. To cancel the selection of a row, set the SelectedIndex property to -1. |
You can control the appearance of the selected row by using the SelectedRowStyle property. Common settings usually include a custom background color, foreground color, and font properties.
The GridView control provides several events that you can use to perform a custom action when a row is selected. The following table lists the available events.
| Event | Description |
|---|---|
| Occurs when a row's Select button is clicked, but after the GridView control handles the select operation. This event is often used to perform a task after a row is selected in the control. | |
| Occurs when a row's Select button is clicked, but before the GridView control handles the select operation. This event is often used to cancel the selection operation. |
Reference
GridView ClassGridView Members
System.Web.UI.WebControls Namespace
CommandField
GridViewRow
GridView.AutoGenerateDeleteButton Property
GridView.AutoGenerateEditButton Property
GridView.AutoGenerateColumns Property
DataKeyNames
SelectedIndex
SelectedRow
SelectedRowStyle
SelectedValue
SelectedIndexChanged
SelectedIndexChanging
Note: