System.Web.UI.WebControls.DetailsView.AutoGenerateEditButton Property

Gets or sets a value indicating whether the built-in controls to edit the current record are displayed in a System.Web.UI.WebControls.DetailsView control.

Syntax

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

Value

Documentation for this section has not yet been entered.

Remarks

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

Note:

For a data source control to update data, its SqlDataSource.UpdateCommand property must be set with an update query statement.

When the DetailsView.AutoGenerateEditButton property is set to true, a System.Web.UI.WebControls.CommandField row field with an Edit button is automatically displayed in the System.Web.UI.WebControls.DetailsView control. Clicking the Edit button puts that System.Web.UI.WebControls.DetailsView control in edit mode. When in edit mode, each bound field in the control that is not read-only displays the appropriate input control, such as a System.Web.UI.WebControls.TextBox control, for the field's data type. This allows the user to modify the field's value.

When clicked, the Edit button is also replaced with an Update button and a Cancel button. Clicking the Update button updates the record in the data source with any value changes and returns the control to the mode specified by the DetailsView.DefaultMode property. Clicking the Cancel button abandons any value changes and returns the control to the default mode.

Note:

To put a System.Web.UI.WebControls.DetailsView control in edit mode programmatically, use the DetailsView.ChangeMode(DetailsViewMode) method.

When the DetailsView.AutoGenerateRows property is also set to true, the System.Web.UI.WebControls.DetailsView control automatically ensures that the field or fields specified in the DetailsView.DataKeyNames property are read-only.

Note:

Unless you implement your own updating functionality, you must set the DetailsView.DataKeyNames property for the automatic updating feature to work.

You can control the appearance of the data rows when the System.Web.UI.WebControls.DetailsView control is in edit mode by using the DetailsView.EditRowStyle property. Common settings usually include a custom background color, foreground color, and font properties.

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

DetailsView.ItemUpdated

Occurs when the Update button is clicked, but after the System.Web.UI.WebControls.DetailsView control updates the record. This event is often used to check the results of the update operation.

DetailsView.ItemUpdating

Occurs when the Update button is clicked, but before the System.Web.UI.WebControls.DetailsView control updates the record. This event is often used to cancel the update operation.

DetailsView.ModeChanged

Occurs after the System.Web.UI.WebControls.DetailsView control changes modes.

DetailsView.ModeChanging

Occurs before the System.Web.UI.WebControls.DetailsView control changes modes. This event is often used to cancel the mode change.

The value of DetailsView.AutoGenerateEditButton 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