日期:2014-05-17 浏览次数:20464 次
<asp:TemplateField HeaderText="数量"> <ItemTemplate> <asp:Label ID="lblcounts0" runat="server" Text='<%# Bind("hm_counts") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="txtcounts" Width="60" runat="server" Text='<%# Bind("hm_counts") %>'></asp:TextBox> </EditItemTemplate> <ItemStyle HorizontalAlign="Center" Width="100px" /> </asp:TemplateField>
//更新事件 protected void gvHTMX_RowUpdating(object sender, GridViewUpdateEventArgs e) { int hm_id = Convert.ToInt32(gvHTMX.DataKeys[e.RowIndex].Value); //下面这个counts是文本框的值 int counts = Convert.ToInt32(((TextBox)gvHTMX.Rows[e.RowIndex].FindControl("txtcounts")).Text); //下面这个numbers是原始数量 int numbers = Convert.ToInt32(((Label)gvHTMX.Rows[e.RowIndex].FindControl("lblcounts0")).Text); string beiz = ((TextBox)gvHTMX.Rows[e.RowIndex].FindControl("txtmxbz")).Text; for (int i = 0; i < list.Count; i++) { if (list[i].Hm_id == hm_id) { list[i].Hm_counts = counts; list[i].Hm_beiz = beiz; } } this.gvHTMX.EditIndex = -1; this.initGvHTMX();//刷新 }
if (!IsPostBack) { int hm_id = Convert.ToInt32(gvHTMX.DataKeys[e.RowIndex].Value); //下面这个counts是文本框的值 int counts = Convert.ToInt32(((TextBox)gvHTMX.Rows[e.RowIndex].FindControl("txtcounts")).Text); //下面这个numbers是原始数量 int numbers = Convert.ToInt32(((Label)gvHTMX.Rows[e.RowIndex].FindControl("lblcounts0")).Text); string beiz = ((TextBox)gvHTMX.Rows[e.RowIndex].FindControl("txtmxbz")).Text; for (int i = 0; i < list.Count; i++) { if (list[i].Hm_id == hm_id) { list[i].Hm_counts = counts; list[i].Hm_beiz = beiz; } } this.gvHTMX.EditIndex = -1; this.initGvHTMX();//刷新 }