这是嵌套的GridView
场景。
我想要隐藏<templatefield>
,其中包含一个<div>
,并且在不显示子gridview时也不应该留空...
<asp:Panel ID="pnlgvwSubjectStatus" runat="server" Style="max-height: 500px; overflow: auto; width: 60%;">
<asp:GridView ID="gvwSubjectForProject" runat="server" AutoGenerateColumns="false" SkinID="grdViewSmlAutoSize" Width="70%" ShowFooter="true" AllowPaging="true" PageSize="1">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="imgbtnExpand" runat="server" ImageUrl="../images/Plus.gif" alt="Expand" OnClientClick="imgbtnExpand_Click" />
<asp:HiddenField ID="hcStatus" runat="server" Value='<%# Eval("cStatus") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Status" HeaderText="STATUS">
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" Wrap="true" Width="40%" />
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="true" Width="40%" />
</asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
<div id="div_gvChild" runat="server" style="max-height: 300px; width: 100%; overflow: auto; text-align: right;">
<asp:Panel ID="pnlOrders" runat="server" Width="100%">
<asp:GridView ID="gvChildGrid" runat="server" AutoGenerateColumns="false" SkinID="grdViewSmlAutoSize">
<Columns>
<asp:BoundField ItemStyle-Width="40%" DataField="vSubjectID" HeaderText="SUBJECT ID">
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" Wrap="true" Width="40%" />
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="true" Width="40%" />
</asp:BoundField>
<asp:BoundField ItemStyle-Width="60%" DataField="FullName" HeaderText="FULL NAME">
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" Wrap="true" Width="60%" />
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="true" Width="60%" />
</asp:BoundField>
</Columns>
</asp:GridView>
</asp:Panel>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="TotalSubject" HeaderText="TOTAL SUBJECTS">
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" Wrap="true" Width="50%" />
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="true" Width="50%" />
</asp:BoundField>
</Columns>
</asp:GridView>
</asp:Panel>
我不想在未显示子GridView
时显示任何左侧空格。
答案 0 :(得分:0)
给它一个id或类,并用jquery:
来定位它$('.div_gvChild-css-class').Show();
//or
$('#div_gvChild').Show();
$('.div_gvChild-css-class').Hide();
//or
$('#div_gvChild').Hide();
要删除空格,请在样式标记中添加“display:none”:
<div id="div_gvChild" runat="server" style="display:none; max-height: 300px; width: 100%; overflow: auto; text-align: right">
如果您希望它看起来更漂亮,可以使用SlideUp()/ SlideDown()函数