System.Web.UI.WebControls.DetailsView.AutoGenerateInsertButton Property

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

Syntax

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

Value

Documentation for this section has not yet been entered.

Remarks

When a data source control that supports inserting 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 inserting functionality.

Note:

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

When the DetailsView.AutoGenerateInsertButton property is set to true, a System.Web.UI.WebControls.CommandField row field with a New button is automatically displayed in the System.Web.UI.WebControls.DetailsView control. Clicking the New button puts that System.Web.UI.WebControls.DetailsView control in insert mode. When in insert 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 enter the field's value for the new record.

When clicked, the New button is also replaced with an Insert button and a Cancel button. Clicking the Insert button inserts the new record in the data source and returns the control to the mode specified by the DetailsView.DefaultMode property. Clicking the Cancel button abandons the insert operation and returns the control to the default mode.

Note:

To put a row in insert mode programmatically, use the DetailsView.ChangeMode(DetailsViewMode) method.

You can control the appearance of a record that is in insert mode by using the DetailsView.InsertRowStyle 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 new record is inserted. The following table lists the available events.

DetailsView.ItemInserted

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

DetailsView.ItemInserting

Occurs when the Insert button is clicked, but before the System.Web.UI.WebControls.DetailsView control inserts the record. This event is often used to cancel the insert 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.AutoGenerateInsertButton 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