datalist1数据源SqlDataSource1,更新事件DataList1_UpdateCommand
Button1:Text="更新" CommandName="update关键代码如下:
<script runat="server">
private void DataList1_UpdateCommand(object source,System.Web.UI.WebControls.DataListCommandEventArgs e)
    {
        TextBox quantity;
        quantity= (TextBox)(e.Item.FindControl("Quantity"));
        string newQuantity = quantity.Text;
        // Add code here to update the Quantity value of the data source
        // using the newQuantity variable. Note taht newQuantity is a
        // string and would have to be converted to a number.        DataList1.EditItemIndex = -1;
        DataList1.DataBind();    }
</script><asp:DataList ID="DataList1" Runat="server"
DataSourceID="SqlDataSource1" OnUpdateCommand="DataList1_UpdateCommand"
DataKeyField="ID" EditItemIndex="0"  OnCancelCommand ="DataList1_CancelCommand"><asp:Button ID="Button1" Runat="server" Text="更新" CommandName="update" />