Gets or sets a value indicating whether a System.Web.UI.WebControls.CommandField field column with an Edit button for each data row is automatically added to a System.Web.UI.WebControls.GridView control.
Documentation for this section has not yet been entered.
When a data source control that supports updating is bound to a System.Web.UI.WebControls.GridView control, the System.Web.UI.WebControls.GridView control can take advantage of the data source control's capabilities and provide automatic updating functionality.
For a data source control to update data, it must be configured to update data. To configure a data source control to update records, see the documentation for the specific data source control.
When the GridView.AutoGenerateEditButton property is set to true, a column (represented by a System.Web.UI.WebControls.CommandField object) with an Edit button for each data row is automatically added to the System.Web.UI.WebControls.GridView control. Clicking an Edit button for a row puts that row in edit mode. When a row is in edit mode, each column field in the row 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 row in the data source with any value changes and returns the row to display mode. Clicking the Cancel button abandons any value changes and returns the row to display mode.
You can programmatically put a row in edit mode by setting the GridView.EditIndex property with the index of the row. To programmatically exit edit mode, set the GridView.EditIndex property to -1.
When using the built-in updating functionality, you must set the GridView.DataKeyNames property with a comma-separated list of field names to identify the primary key field or fields of the data source; otherwise, the built-in updating functionality will not be able to update the correct record. When using automatically generated field columns (by setting the GridView.AutoGenerateColumns property to true), the System.Web.UI.WebControls.GridView control automatically ensures that the automatically generated field columns that correspond to the field or fields specified in the GridView.DataKeyNames property are read-only.
You can control the appearance of a row that is in edit mode by using the GridView.EditRowStyle property. Common settings usually include a custom background color, foreground color, and font properties.
The System.Web.UI.WebControls.GridView control provides several events that you can use to perform a custom action when a row is updated. The following table lists the available events.
GridView.RowCancelingEdit |
Occurs when a row's Cancel button is clicked, but before the System.Web.UI.WebControls.GridView control cancels out of edit mode. This event is often used to stop the canceling operation. |
GridView.RowEditing |
Occurs when a row's Edit button is clicked, but before the System.Web.UI.WebControls.GridView control enters edit mode. This event is often used to cancel the editing operation. |
GridView.RowUpdated |
Occurs when a row's Update button is clicked, but after the System.Web.UI.WebControls.GridView control updates the row. This event is often used to check the results of the update operation. |
GridView.RowUpdating |
Occurs when a row's Update button is clicked, but before the System.Web.UI.WebControls.GridView control updates the row. This event is often used to cancel the updating operation. |