0

我有一个gridview,我有两个按钮编辑和删除。单击编辑按钮后,我将值放入网格外部的文本框中,并显示更新和取消按钮。但这不会触发..

<asp:UpdatePanel ID="UpdatePanel2" runat="server">
          <ContentTemplate>
                <asp:Panel ID="pnladdproduct" runat="server">
                           <div class="mws-form-col-1-8">
                                <asp:Label ID="Label11" runat="server" AssociatedControlID="btnAddProduct">&nbsp;</asp:Label>
                                <div class="mws-form-item large">
                                     <asp:Button ID="btnAddProduct" ValidationGroup="grpProduct" runat="server" CssClass="mws-button red" Text="Add" OnClick="btnAddProduct_Click" />
                                </div>
                           </div>
                </asp:Panel>
                <asp:Panel ID="pnlUpdateProduct" runat="server">
                           <div class="mws-form-col-1-8">
                                <asp:Label ID="Label12" runat="server" AssociatedControlID="btnUpdateProduct">&nbsp;</asp:Label>
                                <div class="mws-form-item large">
                                     <asp:Button ID="btnUpdateProduct" runat="server" CausesValidation="False" CssClass="mws-button blue" Text="Update" OnClick="btnUpdateProduct_Click" />
                                </div>
                          </div>
                </asp:Panel>
                <asp:Panel ID="pnlCancel" runat="server">
                           <div class="mws-form-col-1-8">
                                <asp:Label ID="Label13" runat="server" AssociatedControlID="btnCancelUpdate">&nbsp;</asp:Label>
                                <div class="mws-form-item large">
                                     <asp:Button ID="btnCancelUpdate" CausesValidation="False" runat="server" CssClass="mws-button gray" Text="Cancel" OnClick="btnCancelUpdate_Click" />
                                 </div>
                            </div>
                 </asp:Panel>
                 <div class="mws-form-col-8-8">
                      <asp:GridView ID="grdProduct" ShowHeaderWhenEmpty="True" CssClass="mGrid" runat="server" AutoGenerateColumns="False" AllowPaging="True" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt" OnPageIndexChanging="grdProduct_PageIndexChanging" OnRowDeleting="grdProduct_RowDeleting" OnRowEditing="grdProduct_RowEditing">
                                    <Columns>
                                             <asp:BoundField DataField="Name" HeaderText="Product" SortExpression="Product" />
                                             <asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" />
                                             <asp:BoundField DataField="Rate" HeaderText="Rate" SortExpression="Rate" />
                                             <asp:BoundField DataField="Amount" HeaderText="Amount" SortExpression="Amount" />
                                             <asp:ButtonField ButtonType="Image" CommandName="Edit" HeaderText="Edit" ImageUrl="~/css/icons/16/edit.png" ShowHeader="True" Text="Edit" />
                                             <asp:ButtonField ButtonType="Image" CommandName="Delete" HeaderText="Delete" ImageUrl="~/css/icons/16/delete.png" ShowHeader="True" Text="Delete" />
                                             <asp:TemplateField HeaderText="HiddenColumn">
                                                  <HeaderTemplate>
                                                  </HeaderTemplate>
                                                  <ItemTemplate>
                                                               <asp:HiddenField ID="hdfProductID" runat="server" Value='<%# Bind("ProID") %>' />
                                                  </ItemTemplate>
                                             </asp:TemplateField>
                                    </Columns>
                                              <EmptyDataTemplate>
                                                    No Products Added !!
                                              </EmptyDataTemplate>
                      </asp:GridView>
                      <div class="mws-form-row inline">
                           <asp:Label ID="Label15" runat="server" AssociatedControlID="txtQuantity">Total Amount</asp:Label>
                           <div class="mws-form-item medium">
                                <asp:TextBox ID="txtTotalAmount" BackColor="Beige" BorderColor="red" ReadOnly="True" CssClass="mws-textinput" runat="server"></asp:TextBox>
                           </div>
                      </div>
                 </div>
          </ContentTemplate>
          <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnUpdateProduct"  EventName="Click"/>
                    <asp:PostBackTrigger ControlID="btnCancelUpdate" />                                        
          </Triggers>
</asp:UpdatePanel>

服务器端代码..

 protected void grdProduct_RowEditing(object sender, GridViewEditEventArgs e)
    {

        Session["proID"] = StepGetHiddenValuesFromGridControl(e.NewEditIndex);
        txtQuantity.Text = grdProduct.Rows[e.NewEditIndex].Cells[1].Text;
        txtRate.Text = grdProduct.Rows[e.NewEditIndex].Cells[2].Text;
        txtAmount.Text = grdProduct.Rows[e.NewEditIndex].Cells[3].Text;
        txtQuantity.BackColor = Color.Beige;
        txtRate.BackColor = Color.Beige;
        txtAmount.BackColor = Color.Beige;
        //pnladdproduct.Visible = false;
        //pnlUpdateProduct.Visible = true;
        //pnlCancel.Visible = true;
   }

protected void btnUpdateProduct_Click(object sender, EventArgs e)
    {
        // this code not firing
    }
4

1 回答 1

0

我认为不需要触发器。

于 2012-09-01T10:51:14.987 回答