This is a more advanced example of updating and editing a Gridview control
<asp:sqldatasource ID="ds1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectString %>"
SelectCommand="SELECT ProductID, ProductName, QuantityPerUnit, Discontinued, UnitPrice FROM Products"
UpdateCommand="UPDATE Products SET QuantityPerUnit=@QuantityPerUnit, Discontinued=@Discontinued, UnitPrice=@UnitPrice WHERE ProductID=@ProductID"
DeleteCommand="DELETE FROM Products WHERE ProductID=@ProductID"
/>
<asp:GridView ID="grid1" runat="server" DataSourceID="ds1"
DataKeyNames="ProductID"
AutoGenerateColumns="False"
AllowSorting="True"
AllowPaging="True"
PageSize="5">
<Columns>
<asp:ButtonField ButtonType="Button" DataTextField="ProductID" SortExpression="ProductID"
HeaderText="ID" />
<asp:HyperLinkField DataTextField="ProductName"
DataNavigateUrlFields="ProductID,ProductName"
DataNavigateUrlFormatString="http://www.site-that-shows-more-info.com/products?product={0}&name={1}"
SortExpression="ProductName" HeaderText="Product"
ItemStyle-Font-Bold="True" ItemStyle-BackColor="Yellow" />
<asp:BoundField DataField="QuantityPerUnit" HeaderText="Packaging" />
<asp:CheckBoxField DataField="Discontinued" HeaderText="N/A" />
<asp:TemplateField HeaderText="Price" SortExpression="UnitPrice"
ItemStyle-Font-Bold="True">
<ItemTemplate>
<asp:Label runat="server" text='<%# Eval("UnitPrice", "${0:F2}") %>' />
</ItemTemplate>
<AlternatingItemTemplate>
<asp:Label runat="server" ForeColor="DarkGray" text='<%# Eval("UnitPrice", "${0:F2}") %>' />
</AlternatingItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="UnitPrice" runat="server" Text='<%#Bind("UnitPrice")%>' />
<asp:RequiredFieldValidator ID="rfv1" runat="server"
ControlToValidate="UnitPrice" Text="You must enter the price" />
</EditItemTemplate>
</asp:TemplateField>
<asp:CommandField ButtonType="Image" ShowCancelButton="True"
ShowEditButton="True" ShowDeleteButton="True"
CancelImageUrl="s.gif" EditImageUrl="q.gif"
UpdateImageUrl="i.gif" DeleteImageUrl="x.gif"
CancelText="Cancel this update" EditText="Edit this row"
UpdateText="Apply these changes" DeleteText="Delete this row" />
</Columns>
<HeaderStyle Font-Bold="true" Font-Names="Verdana" />
<RowStyle Font-Names="Verdana" />
</asp:GridView>