Here's a quick hack if you should use Repeater :
In .aspx:
<asp: Repeater ID = 'rptr' runat = 'server'>
<HeaderTemplate>
<table>
<thead>
<tr>
<th>
Always visible header col
</th>
<th id = 'thHidable' runat = 'server' class = 'hideable'>
Hideable header col
</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
Repeated col
</td>
<td id = 'tdHideable' runat = 'server' class = 'hideable'>
Hideable repeated col
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody> </table>
</FooterTemplate>
</ asp: Repeater>
In the code behind (when using C #):
protected override void Page_Init() { this.rptr.ItemDataBound += new RepeaterItemEventHandler(rptr_ItemDataBound); } void rptr_ItemDataBound(object sender, RepeaterItemEventArgs e) { RepeaterItem item = (RepeaterItem)e.Item; if (item.ItemType == ListItemType.Header) { HtmlTableCell thHidable = (HtmlTableCell)item.FindControl("thHidable"); if (hideCondition) { // thHidable.Visible = false; // do not render, not usable by client script (use this approach to prevent data from being sent to client) thHidable.Style["display"] = "none"; // rendered hidden, can be dynamically shown/hidden by client script } } else if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { HtmlTableCell tdHideable = (HtmlTableCell)item.FindControl("tdHideable"); if (hideCondition) { // tdHideable.Visible = false; // do not render, not usable by client script (use this approach to prevent data from being sent to client) tdHideable.Style["display"] = "none"; // rendered hidden, can be dynamically shown/hidden by client script } } }
(optional) If you want to dynamically display a client-side column (assuming it has been rendered) using jQuery (for short):
$(".hideable").show();
source share