I have a table with a specific layout. It starts like this:
<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>
The problem is, under certain conditions I need it to look like this:
<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>
I've hidden textboxes before, that's no problem. But the only way I can think of to do this is to hide td's
using code. I've seen this:
How to hide columns in HTML table?
but they never explain how you can determine which td
is to be hidden.
So, can this be done in code (preferably code-behind in C#)? If so, how?