【发布时间】:2016-04-18 16:43:08
【问题描述】:
我有一张具有特定布局的桌子。开头是这样的:
<table>
<tr bgcolor="#007ACC" style="color:White">
<td width="145"><asp:Label Text="" ID="lblLevel" runat="server" /></td><td width="80"></td><td width="30"></td><td width="145"><asp:Label Text="" ID="lblGroupNumber" runat="server" /></td><td width="60"></td><td width="10">Active</td>
</tr>
<tr>
<td colspan="5">
<asp:TextBox ID="txtName" runat="server" width="460px"></asp:TextBox>
</td>
<td>
<asp:DropDownList ID="cboActive" runat="server" Width="50px">
<asp:ListItem>Y</asp:ListItem>
<asp:ListItem>N</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
问题是,在某些情况下,我需要它看起来像这样:
<table>
<tr bgcolor="#007ACC" style="color:White">
<td width="145"><asp:Label Text="" ID="lblLevel" runat="server" /></td><td width="80"></td><td width="30"></td><td width="145"><asp:Label Text="" ID="lblGroupNumber" runat="server" /></td><td width="60"></td><td width="10">Active</td>
</tr>
<tr>
<td colspan="2">
<asp:TextBox ID="txtName" runat="server" width="460px"></asp:TextBox>
</td>
<td></td>
<td colspan="2">
<asp:TextBox ID="txtNumber" runat="server" width="460px"></asp:TextBox>
</td>
<td>
<asp:DropDownList ID="cboActive" runat="server" Width="50px">
<asp:ListItem>Y</asp:ListItem>
<asp:ListItem>N</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
我以前隐藏过文本框,没问题。但我能想到的唯一方法是使用代码隐藏td's。我看过这个:
How to hide columns in HTML table?
但他们从不解释如何确定要隐藏哪个 td。
那么,这可以在代码中完成吗(最好是 C# 中的代码隐藏)?如果有,怎么做?
【问题讨论】:
标签: c# asp.net html-table code-behind