Export (0) Print
Expand All
Expand Minimize

DetailsView.AutoGenerateDeleteButton Property

Gets or sets a value indicating whether the built-in control to delete the current record is displayed in a DetailsView control.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

abstract AutoGenerateDeleteButton : bool with get, set 
override AutoGenerateDeleteButton : bool with get, set
<asp:DetailsView AutoGenerateDeleteButton="True|False" />

Property Value

Type: System.Boolean
true to display the built-in control to delete the current record; otherwise, false. The default is false.

When a DetailsView control is bound to an object that inherits from DataSourceView and the CanDelete property returns true, the DetailsView control can take advantage of the data source control's capabilities and provide automatic deleting functionality.

NoteNote

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

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

NoteNote

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

The 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.

Event

Description

ItemDeleted

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

ItemDeleting

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

The value of AutoGenerateDeleteButton is stored in view state.

The following code example demonstrates how to use the AutoGenerateDeleteButton property to display the built-in control to delete the current record.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft