Ram Singh Ram Singh -4 years ago 78
ASP.NET (C#) Question

display and hide particular column in repeater?

I have a repeater. And i want to hide and display a particular column for a particular condition. I have three types of subjects and their ids are 0,1,2 respectively. Now i want to show that particular column when the subject will be 2 only..

My code is :-

<table id="table1" class="yui" cellpadding="0" cellspacing="0">
<a href='#' title="Click Header to Sort">EmpID #</a>

<asp:Repeater ID="Repaddressorbbl" runat="server" OnItemCommand="Repaddressorbbl_ItemCommand">

<tr id="gh" style="cursor: pointer" onclick="Select(this);">
<td style="text-align: center;">
<asp:LinkButton ID="lknumber" runat="server" Text="Edit" CommandName="subjectid" />


Answer Source

I think you should start by using <HeaderTemplate></HeaderTemplate> and <FooterTemplate></FooterTemplate> to define the start and end of your table just to tidy it up.

You can get the table to run on the server by adding a runat="server" and give the column <td> an id and a runat="server" attribute so you can program server code against it. I'd then eval bind the visible attribute of the cell based on your field value or use attributes.add("display:none") or just use a grid view as suggested in the link.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download