2017-12-18 218 views
0

我有一個gridview有2列([+]和[data])。點擊[+]符號可以在同一個網格視圖中打開網格視圖。在Gridview中顯示Gridview

現在,在子網格視圖中,我有一個鏈接按鈕,點擊後,我顯示一些數據。在回發gridview保留其原來的位置,我想顯示子網格視圖。

代碼。

<asp:GridView ID="grvNeverTouchedQuartile" class="form-table" Width="100%" OnRowCommand="grvNeverTouchedQuartile_RowCommand" 
                   AutoGenerateColumns="false" runat="server" OnRowDataBound="grvNeverTouchedQuartile_RowDataBound" 
                   DataKeyNames="QuartileType"> 
                   <Columns> 
                    <asp:TemplateField> 
                     <ItemTemplate> 
                      <%--<asp:LinkButton ID="lnkbtnNTQuartile" runat="server" Text='<%# Eval("Quartile") %>' 
                     CommandArgument='<%# Eval("QuartileType") %>' CommandName="NeverTouched"></asp:LinkButton>--%> 
                      <img alt="Image not available" style="cursor: pointer" src="../images/plus.png" /> 
                      <asp:Panel ID="pnl_NTChildGrid" runat="server" Style="display: none"> 
                       <table> 
                        <tr> 
                         <td> 
                          <div style="overflow: auto;"> 
                           <asp:GridView ID="grdNTInsuranceData" runat="server" AutoGenerateColumns="false" OnRowCommand="grdNTInsuranceData_RowCommand"> 
                            <Columns> 
                             <asp:TemplateField HeaderText="Insurance Name"> 
                              <ItemTemplate> 
                               <asp:Label ID="lblNTQuartileType" runat="server" Text='<%# Eval("QuartileType") %>' Visible="false"></asp:Label> 
                               <asp:Label ID="lblNTInsuranceName" runat="server" Text='<%# Eval("InsuranceName") %>' Visible="false"></asp:Label> 
                               <asp:LinkButton ID="lnkbtnNTInsuranceQuartile" runat="server" Text='<%# Eval("InsuranceNameDetails") %>' 
                                CommandArgument='<%# ((GridViewRow) Container).RowIndex %>' CommandName="NeverTouchedInsurance"></asp:LinkButton> 
                              </ItemTemplate> 
                             </asp:TemplateField> 
                            </Columns> 
                           </asp:GridView> 
                          </div> 
                         </td> 
                        </tr> 
                       </table> 
                      </asp:Panel> 
                     </ItemTemplate> 
                    </asp:TemplateField> 
                    <asp:TemplateField HeaderText="Quartile[Count - $Value]"> 
                     <ItemTemplate> 
                      <asp:Label ID="lblNTQuartile" runat="server" Text='<%# Eval("Quartile") %>'></asp:Label> 
                      <%--<asp:LinkButton ID="lnkbtnNTQuartile" runat="server" Text='<%# Eval("Quartile") %>' 
                     CommandArgument='<%# Eval("QuartileType") %>' CommandName="NeverTouched"></asp:LinkButton>--%> 
                     </ItemTemplate> 
                    </asp:TemplateField> 
                   </Columns> 
                  </asp:GridView> 

在此先感謝!

+0

你有沒有試過代碼?然後在此處提供以獲得更好的幫助。 – Aria

+0

@Aria,我編輯了我的問題。請看看它。 –

+0

所以你說你的主要問題是點擊子網格中的鏈接按鈕後,刷新子網格關閉後刷新頁面? – Aria

回答

0

有一些方法(這是不是與代碼,這只是我的建議,有超過互聯網代碼或它是基於經驗)所以在我看來,你可以使用以下情況之一:

1-您應該使用UpdatePanel防止清爽頁面,並把網格內UpdatePanel,只是樣品象下面這樣:

<asp:UpdatePanel ID="panelId" UpdateMode="Conditional" runat="server" > 
    <ContentTemplate> 
    <asp:GridView ID="gvPrList" runat="server" AutoGenerateColumns="false" AllowPaging="false" 
      AllowSorting="false" CssClass="list-table" HeaderStyle-CssClass="header"> 
      <Columns> 
     <ItemTemplate> 
        <asp:LinkButton ID="lnkbtnNTInsuranceQuartile" runat="server" Text='<%# Eval("InsuranceNameDetails") %>' 
                                CommandArgument='<%# ((GridViewRow) Container).RowIndex %>' CommandName="NeverTouchedInsurance"></asp:LinkButton> 
       </ItemTemplate> 
      </asp:TemplateField> 
     </Columns> 
</asp:GridView> 
</ContentTemplate> 
</asp:UpdatePanel> 

2-的lnkbtnNTInsuranceQuartilerunatserver其主後,它的點擊後,後面會發生,從而使頁面獲得爲此刷新你可以改變你的lnkbtnNTInsuranceQuartile到HTML元素,如<div><a class="x">click here</a><span class="detail"/></div>,然後代替lnkbtnNTInsuranceQuartile點擊使用ajax,然後更新細節跨度是這樣的:

$('.x').click(function() { 
    var $me = this; 
    $.ajax({ 
     url: 'Your Web Method address', 
     data: { youData}, 
     contentType: "application/json; charset=utf-8", 
     dataType: "json", 
     success: function (data) { 
      //update span here 
      $me.parent().find('.details.'.html(your response); 
     }, 
     error: function (x, e) { 
     } 
    }); 
}); 

3-使用客戶端電網不ASP.Net的GridView

4-加倒塌的th ID爲localstorage和頁面加載後再次打開它......

5-等等

三個以上步驟可以基於你的場景實施...

希望能幫到你