|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
How to: Enable Default Editing in the GridView Web Server Control
In addition to displaying data, thecontrol supports an edit mode in which users can change the contents of an individual row. You can configure the GridView control to display an Edit button in each row. When users click the button, the row is redisplayed in edit mode, with the data available in editable controls such as and controls. The Edit button becomes an Update or Save button, and when users click it, the updated row is written back to the data store. You can add editing capability to the GridView control without writing any code.
The following procedure illustrates how to enable default editing in the GridView control.
To enable default editing using the smart tag
In Design view, right-click the GridView control and click Show Smart Tag.
In the smart tag panel, select Enable Editing.
The Enable Editing check box appears in the smart tag panel only if the data source control to which GridView control is bound supports editing. For example, if the GridView control is bound to acontrol, the SqlDataSource control's property must contain a SQL Update statement.
Alternatively, you can set a GridView control property.
To enable default editing using the AutoGenerateEditButton property
Select the GridView control, and in the Properties window, set AutoGenerateEditButton to true.
In Source view, in the <asp:GridView> element, set AutoGenerateEditButton to true, as in the following example:
<asp:GridView Runat="server" ID="GridView1" AutoGenerateEditButton="true" />