System.Web.UI.WebControls Namespace DetailsView Class
.NET Framework version 2.0
Sets or retrieves a value specifying whether the built-in controls to insert a new record are automatically added and displayed in a DetailsView control.
Inline |
<asp:detailsview autogenerateinsertbutton = true | false ... > |
Script |
DetailsView.AutoGenerateInsertButton [ = true | false ] |
This property accepts or returns only a boolean value: true if the built-in controls to insert a new record are automatically added and displayed; otherwise, false. Default value is false.
Use this property to specify whether the built-in controls to insert a new record are automatically added and displayed in a DetailsView control.
Clicking the New button for a row puts the control into insert mode, and input controls are displayed for each
field in the record, allowing the user to enter the values for the new record. The New button for the record is replaced with an Insert button and a Cancel button, and all other command buttons for the record are hidden. Clicking the Insert button adds the record with the new values to the data source, whereas clicking the Cancel button cancels the operation.
Note that for the automatic insert feature to work, the DetailsView must be bound to a data source control that is configured to insert data, meaning the InsertCommand must have been properly set.
The DetailsView control raises the following events to which you can assign a custom action to perform when a row is insertd.
Event |
Description |
ItemInserted |
Occurs when the Insert button is clicked, but after the DetailsView control inserts the record. This event is often used to check the results of the insert operation. |
ItemInserting |
Occurs when the Insert button is clicked, but before the DetailsView control updates the record. This event is often used to cancel the insert operation. |
ModeChanged |
Occurs after the DetailsView control changes modes. |
ModeChanging |
Occurs before the DetailsView control changes modes. This event is often used to cancel the mode change. |
The following example demonstrates how to use the AutoGenerateInsertButton property to display the built-in controls to insert a new record in a DetailsView control.
Show me
DetailsView Members AutoGenerateDeleteButton AutoGenerateEditButton Allowing Users to Insert Rows in a DetailsView Control