System.Web.UI.WebControls.GridView.AutoGenerateDeleteButton Property

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

Syntax

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

Value

Documentation for this section has not yet been entered.

Remarks

When a data source control that supports deleting is bound to a System.Web.UI.WebControls.GridView control, the System.Web.UI.WebControls.GridView control can take advantage of the data source control's capabilities and provide automatic deleting functionality.

Note:

For a data source control to delete data, it must be configured to delete data. To configure a data source control to delete records, see the documentation for the specific data source control.

When the GridView.AutoGenerateDeleteButton property is set to true, a column (represented by a System.Web.UI.WebControls.CommandField object) with a Delete button for each data row is automatically added to the System.Web.UI.WebControls.GridView control. Clicking the Delete button for a row permanently removes that record from the data source.

Note:

You must also set the GridView.DataKeyNames property to identify the key field or fields of the data source for the automatic deleting feature to work.

The System.Web.UI.WebControls.GridView control provides several events that you can use to perform a custom action when a row is deleted. The following table lists the available events.

GridView.RowDeleted

Occurs when a row's Delete button is clicked, but after the System.Web.UI.WebControls.GridView control deletes the record from the data source. This event is often used to check the results of the delete operation.

GridView.RowDeleting

Occurs when a row's Delete button is clicked, but before the System.Web.UI.WebControls.GridView control deletes the record from the data source. This event is often used to cancel the deleting operation.

Requirements

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