System.Web.UI.WebControls Namespace CommandField Class
.NET Framework version 2.0
Sets or retrieves a value indicating whether a New button is displayed in a CommandField.
Inline |
<asp:commandfield showinsertbutton = true | false ... > |
Script |
CommandField.ShowInsertButton [ = true | false ] |
This property accepts or returns only a boolean value: true to display a New button in a CommandField; otherwise, false. Default value is false.
Use the ShowInsertButton property to specify whether a New button is displayed for each data row in a CommandField control.
NOTE: This property applies only to data-bound controls that support insert operations, such as the 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 CommandField must be bound to a data source control that is configured to insert data, meaning the InsertCommand must have been properly set.
When the ButtonType property of a CommandField is set to Button or Link, use the InsertText property to specify the text to display for an Insert button.
Alternatively, you can display an image by first setting the ButtonType property to Image and then setting the InsertImageUrl property.
The following example demonstrates how to use the ShowInsertButton property to display a New button in a DetailsView control.
Show me
CommandField Members ShowCancelButton ShowDeleteButton ShowEditButton ShowSelectButton