2012-07-02 120 views
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; 
    } 

感謝

維傑

回答

1

問題是因爲文本框是出更新面板,所以乾脆把一切在更新面板中,它將開始運行或只是註釋掉更新面板然後嘗試相同的事情。

+0

感謝很多snudal它現在工作正常 – VijayMathew

+0

很高興看到你的問題通過我的回覆解決:) –