System.Web.UI.WebControls.GridView.AutoGenerateSelectButton Property

Gets or sets a value indicating whether a System.Web.UI.WebControls.CommandField field column with a Select button for each data row is automatically added to a System.Web.UI.WebControls.GridView control.

Syntax

[System.ComponentModel.DefaultValue(false)]
public virtual bool AutoGenerateSelectButton { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

When the GridView.AutoGenerateSelectButton property is set to true, a column (represented by a System.Web.UI.WebControls.CommandField object) with a Select button for each data row is automatically added to the System.Web.UI.WebControls.GridView control. Clicking the Select button for a row selects that row in the control, which sets the GridView.SelectedIndex property to the index of the row. To retrieve the System.Web.UI.WebControls.GridViewRow object that represents the selected row, use the GridView.SelectedRow property. You can also get the primary key value for the selected record by using the GridView.SelectedValue property. The GridView.SelectedValue property contains the values of the key fields specified in the GridView.DataKeyNames property.

Note:

You can programmatically select a row by setting the GridView.SelectedIndex property. To cancel the selection of a row, set the GridView.SelectedIndex property to -1.

You can control the appearance of the selected row by using the GridView.SelectedRowStyle property. Common settings usually include a custom background color, foreground color, and font properties.

The System.Web.UI.WebControls.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.

GridView.SelectedIndexChanged

Occurs when a row's Select button is clicked, but after the System.Web.UI.WebControls.GridView control handles the select operation. This event is often used to perform a task after a row is selected in the control.

GridView.SelectedIndexChanging

Occurs when a row's Select button is clicked, but before the System.Web.UI.WebControls.GridView control handles the select operation. This event is often used to cancel the selecting operation.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0