ASP.NET Data Update - Using GridView and SqlDataSource

Update Data using GridView and SqlDataSource
GridViewDataEditExample.aspx

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

<!DOCTYPE html">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>asp.net Data Update example: using GridView and SqlDataSource</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Green">GridView Data Update Example</h2>
        <asp:SqlDataSource 
            ID="SqlDataSource1"
            runat="server"
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            SelectCommand="SELECT ProductID, ProductName, UnitPrice FROM Products"
            UpdateCommand="UPDATE Products SET ProductName=@ProductName, UnitPrice=@UnitPrice WHERE ProductID=@original_ProductID"
            OldValuesParameterFormatString="original_{0}"
            >
            <UpdateParameters>
                <asp:Parameter Name="ProductID" Type="Int32" />
                <asp:Parameter Name="ProductName" Type="String" />
                <asp:Parameter Name="UnitPrice" Type="Double" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:GridView 
            ID="GridView1"
            runat="server"
            DataSourceID="SqlDataSource1"
            DataKeyNames="ProductID"
            AllowPaging="true"
            PageSize="10"
            AutoGenerateEditButton="true"
            BackColor="AliceBlue"
            ForeColor="SeaGreen"
            HeaderStyle-BackColor="SeaGreen"
            HeaderStyle-ForeColor="AliceBlue"
            BorderColor="LightGreen"
            >
        </asp:GridView>
    </div>
    </form>
</body>
</html>
More asp.net examples