I have browsed the different cases already answered about the topic but did not find the one answering my question:
<asp:ListView ID="lstView_phoneUsersExtensionsFound" runat="server" OnItemDataBound="lstView_phoneUsersExtensionsFound_ItemDataBound">
<LayoutTemplate>
<table id="tbl1" runat="server" class="bordered">
<tr id="tr1" runat="server">
<th id="th1" runat="server" visible='<%# selectOptionVisible %>' >Select</th>
<th id="th1" runat="server">UserID</th>
<th id="th2" runat="server">Firstname</th>
<th id="th3" runat="server">Lastname</th>
</tr>
<tr id="ItemPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td runat="server" visible='<%# selectOptionVisible %>' >
<input type="radio" name="rdbutton_userSelection" value='<%# Eval("uuid") %>' />
<asp:HiddenField runat="server" ID="hdfield_userID" Value='<%# Eval("uuid")%>' />
</td>
<td><asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# String.Format("~/Users/DisplayUserDetails.aspx?selectedCCMUserID={0}&uuid={1}",Eval("userID"),Eval("uuid"))%>'><%# Eval("userID")%></asp:HyperLink></td>
<td><%# Eval("firstname")%></td>
<td><%# Eval("lastname")%></td>
</tr>
</ItemTemplate>
<EmptyDataTemplate></EmptyDataTemplate></asp:ListView>
The repeater layouttemplate header does not take into account the visible value but the different items work well and hide the cell when needed. I would like to keep using an aspx function and not go through javascript or CSS if possible. Any idea?
Well the below code does the trick but I am sure there should be a better way.
protected void lstView_phoneUsersExtensionsFound_ItemDataBound(object sender, ListViewItemEventArgs e)
{
HtmlTableCell th_selectColumn = (HtmlTableCell)lstView_phoneUsersExtensionsFound.FindControl("th1");
th_selectColumn.Visible = selectOptionVisible;
}