|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 Deleting in the GridView Web Server Control
Thecontrol supports a delete mode in which users can delete the current row from the data source. You can add delete capability to the GridView control without writing any code. You can configure the GridView control to display a Delete button in each row. When users click the button, the row is deleted from the data source and the grid is redisplayed.
Deleting data using the GridView control is permanent; you cannot undo the deletion.
To enable default deleting using the smart panel
Right-click the GridView control and click Show Smart Tag.
In the smart tag panel, select Enable Deleting.
The Enable Editing check box appears in the smart tag panel only if the data source control to which GridView control is bound supports deleting. For example, if the GridView control is bound to acontrol, the SqlDataSource control's property must contain a SQL Delete statement.
Alternatively, you can set a GridView control property.
To enable deleting using the AutoGenerateDeleteButton property
Select the GridView control, and in the Properties window, set AutoGenerateDeleteButton to true.
In Source view, in the <asp:GridView> element, set theproperty to true, as in the following example:
<asp:GridView Runat="server" ID="GridView1" AutoGenerateDeleteButton="true" />