System.Web.UI.WebControls.DetailsView.AutoGenerateDeleteButton Property

Gets or sets a value indicating whether the built-in control to delete the current record is displayed in a System.Web.UI.WebControls.DetailsView 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 System.Web.UI.WebControls.DetailsView control is bound to an object that inherits from System.Web.UI.DataSourceView and the System.Web.UI.DataSourceView.CanDelete property returns true, the System.Web.UI.WebControls.DetailsView control can take advantage of the data source control's capabilities and provide automatic deleting functionality.

Note:

For a System.Web.UI.WebControls.SqlDataSourceView object to delete data, the SqlDataSource.DeleteCommand property of the underlying System.Web.UI.WebControls.SqlDataSource object must be set with a delete query statement.

When the DetailsView.AutoGenerateDeleteButton property is set to true, a System.Web.UI.WebControls.CommandField row field with a Delete button is automatically displayed in the System.Web.UI.WebControls.DetailsView control. Clicking the Delete button permanently removes that record from the data source.

Note:

You must also set the DetailsView.DataKeyNames property for the automatic deletion feature to work.

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

DetailsView.ItemDeleted

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

DetailsView.ItemDeleting

Occurs when the Delete button is clicked, but before the System.Web.UI.WebControls.DetailsView control deletes the record from the data source. This event is often used to cancel the delete operation.

The value of DetailsView.AutoGenerateDeleteButton is stored in view state.

Requirements

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