在Gridview中显示Gridview

在Gridview中显示Gridview

问题描述:

我有一个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

有一些方法(这是不是与代码,这只是我的建议,有超过互联网代码或它是基于经验)所以在我看来,你可以使用以下情况之一:

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-等等

三个以上步骤可以基于你的场景实施...

希望能帮到你