[英]Show Gridview inside a Gridview
我有2列([+]和[数据])的gridview。 单击[+]符号,将在同一gridview中打开girdview。
现在,在子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>
提前致谢!!!
有几种方法(这不是代码,这只是我的建议,互联网上有代码,或者是基于经验的),所以我认为您可以使用以下情况之一:
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- runat
的lnkbtnNTInsuranceQuartile
是server
,其主后,它的点击后回会发生,从而使页面刷新得此你可以改变你lnkbtnNTInsuranceQuartile
到HTML元素,如<div><a class="x">click here</a><span class="detail"/></div>
,然后使用ajax
代替lnkbtnNTInsuranceQuartile
,然后更新详细信息,例如:
$('.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-使用客户端Grid而不是ASP.Net GridView
4-将折叠的th
的id添加到localstorage
并在页面加载后再次将其打开...
5等
可以根据您的方案实施以上所有三个步骤...
希望能帮到您
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.