0

我真的很沮丧为我的场景找到解决方案。我有两个网格,第一个网格用于显示商店信息,第二个网格用于编辑与商店信息相关的优惠。当用户编辑第二个网格时,我只会更新与网格选择行相关的文本框值。在我的文件后面的代码中,我可以看到从网格中获取数据并分配到文本框中,但是当函数调用(imgEdit_click)完成时,页面不显示值。编辑功能可以通过多种方式完成,但我的场景是我之前解释的。我有检查页面,在我找不到解决方案的方法之后没有调用回发操作,任何人都可以帮我弄清楚。

以下是我的源代码和代码背后的代码。

我的设计来源:

<div class="field">

 <asp:TextBox ID="txtareaOfferDesc" runat="server" TextMode="MultiLine" ></asp:TextBox>
                    </div>

<div class="field">
 <asp:TextBox ID="txtTimeStarts" runat="server" CssClass="textfield"></asp:TextBox>
                                          <cc1:CalendarExtender   
            ID="CalendarExtender2"  
            runat="server"  
            TargetControlID="txtTimeStarts"    
            CssClass="CalendarCSS">
            </cc1:CalendarExtender> 


<div class="datefld">
<label class="name">Offer end date/time (optional)</label>
 <div class="field">
<asp:TextBox ID="txtTimeEnd" runat="server" CssClass="textfield"></asp:TextBox>

   <cc1:CalendarExtender ID="CalendarExtender4" runat="server" TargetControlID="txtTimeEnd"    
            CssClass="CalendarCSS">
            </cc1:CalendarExtender> ` 

    <asp:GridView ID="gvShopDeal" runat="server" AutoGenerateColumns="false" 
                      CssClass="tblexistoffer" DataKeyNames="ShopID" AllowPaging="True" 
                      AllowSorting="True">
                     <Columns>
                    <asp:TemplateField>
         <HeaderTemplate  >
            <asp:CheckBox ID="chkHeader" runat="server" />
            <asp:Label ID="lblSelectAll" Text="Select All" runat="server"></asp:Label>
         </HeaderTemplate>
         <ItemTemplate >
            <asp:CheckBox ID="chkRow" runat="server" />
         </ItemTemplate>
      </asp:TemplateField>
       <asp:BoundField DataField="ShopID" HeaderStyle-Width="10%" HeaderText="Shop ID" />
      <asp:BoundField DataField="ShopName" HeaderStyle-Width="40%" HeaderText="Shop Name" />
      <asp:BoundField DataField="Street" HeaderStyle-Width="40%" HeaderText="Street" />
      <asp:BoundField DataField="City" HeaderText ="City" />
                </Columns>
              </asp:GridView>
<asp:Button ID="btnCreateDeal" runat="server" Text="Create Offer" 
                      CssClass="grnbtn" OnClientClick="return CheckDealValidation(this)" onclick="btnCreateDeal_Click"></asp:Button>
                                        <asp:Button ID="btnDefCancel" runat="server" Text="Cancel" CssClass="greybtn"></asp:Button>



    <asp:UpdatePanel ID="UpdateExistingOffer" runat="server">
            <ContentTemplate>
              <asp:GridView ID="gvExistingOffers" runat="server" CssClass="tblexistoffer" 
                  AutoGenerateColumns="false" DataKeyNames="OfferID" AllowPaging="True" 
                  AllowSorting="True">

              <Columns>
   <asp:BoundField DataField="OfferID" HeaderText="OfferID" />
<asp:BoundField DataField="Description" HeaderText="OfferName" />
<asp:BoundField DataField="Status" HeaderText="Status" />
<asp:BoundField DataField="OfferType" HeaderText="OfferType" />

<asp:BoundField DataField="StartDate" HeaderText="StartDate">
<ItemStyle CssClass="Hide" />
<HeaderStyle CssClass="Hide" />
</asp:BoundField>
<asp:BoundField DataField="EndDate" HeaderText="EndDate" >
<ItemStyle CssClass="Hide" />
<HeaderStyle CssClass="Hide" />
</asp:BoundField>
 <asp:TemplateField HeaderText="Edit" HeaderStyle-Width="5%">
<ItemTemplate>

<asp:ImageButton ID="imgbtnEdit" ImageUrl="~/Merchant/images/edit.jpg"  runat="server"  Width="25" Height="25" onclick="imgbtnEdit_Click" />

</ItemTemplate>
</asp:TemplateField>
  </Columns>

              </asp:GridView>
              </ContentTemplate>
              </asp:UpdatePanel>

文件后面的代码:

 protected void imgbtnEdit_Click(object sender, ImageClickEventArgs e)
    {

            ImageButton btndetails = sender as ImageButton;
            GridViewRow gvrow = (GridViewRow)btndetails.NamingContainer;
            fferIDForShop = Convert.ToInt32(gvExistingOffers.DataKeys[gvrow.RowIndex].Value);
            ShopList objShopID = ShopService.GetShopID(OfferIDForShop);
            (txtareaOfferDesc.Text) = gvrow.Cells[1].Text.Trim();
            txtTimeStarts.Text = gvrow.Cells[4].Text;
            txtTimeEnd.Text = gvrow.Cells[5].Text;
    }

谢谢

维杰

4

1 回答 1

1

问题是因为文本框不在更新面板中,所以只需将所有内容放在更新面板中它就会开始运行,或者只是注释掉更新面板,然后尝试同样的事情。

于 2012-07-02T13:24:03.453 回答