ASP.NET GridView and SqlDataSource example - Updating data

GridView and SqlDataSource to update data
GridViewEditExample.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>asp.net GridView and SqlDataSource example: updating data</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Gray">Example: Updating Data</h2>
        <asp:SqlDataSource
             ID="SqlDataSource1"
             runat="server"
             ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
             SelectCommand="SELECT CategoryID, CategoryName, Description FROM Categories"
             UpdateCommand="UPDATE Categories SET CategoryName=@CategoryName, Description=@Description WHERE CategoryID=@original_CategoryID"
             OldValuesParameterFormatString="original_{0}"
             >
        </asp:SqlDataSource>
        <asp:GridView
             ID="GridView1" 
             runat="server"
             DataSourceID="SqlDataSource1"
             DataKeyNames="CategoryID"
             AutoGenerateColumns="false"
             AutoGenerateEditButton="true"
             BackColor="HotPink"
             ForeColor="AntiqueWhite"
             BorderColor="Orange"
             BorderStyle="Double"
             BorderWidth="2"
             AllowSorting="false"
             AllowPaging="true"
             PageSize="5"
             HeaderStyle-BackColor="DarkOrange"
             >
            <Columns>
                <asp:BoundField HeaderText="Category ID" DataField="CategoryID" />
                <asp:BoundField HeaderText="Category Name" DataField="CategoryName" />
                <asp:BoundField HeaderText="Description" DataField="Description" />
            </Columns>
        </asp:GridView>
    </div>
    </form>
</body>
</html>
More asp.net examples