asp.net.ph

GridView.AutoGenerateEditButton Property

System.Web.UI.WebControls Namespace   GridView Class


.NET Framework version 2.0

Sets or retrieves a value specifying whether a CommandField column with an Edit button for each data row is automatically added and displayed in a GridView control.

Syntax


Inline <asp:gridview autogenerateeditbutton = true | false ... >
Script GridView.AutoGenerateEditButton [ = true | false ]

Property Value

This property accepts or returns only a boolean value: true if a CommandField column with an Edit button for each data row is automatically added and displayed; otherwise, false. Default value is false.

Remarks

Use this property to automatically add a CommandField column with an Edit button for each data row in a GridView control.

Clicking the Edit button for a row puts the control into edit mode, and input controls are displayed for each field in the record, allowing the user to edit the values for the record. The Edit button for the record is replaced with an Update button and a Cancel button, and all other command buttons for the record are hidden. Clicking the Update button updates the record with the new values in the data source, whereas clicking the Cancel button cancels the operation.

Note that for the automatic editing feature to work, the GridView must be bound to a data source control that is configured to edit data, meaning the UpdateCommand must have been properly set.

In addition, the DataKeyNames property must be set to specify the key field or fields of the data source that will identify the record to edit.

The GridView control raises the following events to which you can assign a custom action to perform when a row is edited.

Event Description
RowCancelingEdit Occurs when a row's Cancel button is clicked, but before the GridView control cancels out of edit mode. This event is often used to stop the canceling operation.
RowEditing Occurs when a row's Edit button is clicked, but before the GridView control enters edit mode. This event is often used to cancel the editing operation.
RowUpdated Occurs when a row's Update button is clicked, but after the GridView control updates the row. This event is often used to check the results of the update operation.
RowUpdating Occurs when a row's Update button is clicked, but before the GridView control updates the row. This event is often used to cancel the updating operation.

Example

The below snippet demonstrates how to use the AutoGenerateEditButton property to enable the automatic editing feature of a GridView control.

<asp:gridview id = "messagesGrid" runat = "server"
   datasourceid = "messages"
   datakeynames = "MessageID"
   autogeneratecolumns = "false"
   autogenerateeditbutton ... >
GridView AutoGenerateEditButton Example
Run Sample | View Source
See Also

GridView Members   AutoGenerateDeleteButton   AutoGenerateSelectButton   Allowing Users to Edit Rows in a GridView Control Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph