I'm having a bit of trouble with my ASP.NET Repeater control. I need to show some HTML depending on a boolean property on the object in the collection that the repeater is bound to.
I have this code:
<asp:Repeater ID="rptListPartners" runat="server" OnItemDataBound="rptListPartners_ItemDataBound">
<HeaderTemplate>
<table border="0" cellpadding="7" cellspacing="0">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td style="font-family:Verdana; font-size:11px; height: 18px; width:370px;">
<div id="data_tooltip_from_div<%#Eval("id") %>" style="display:none; z-index:10;"><%#Eval("profile") %></div>
<a id="tooltip_from_div<%#Eval("id") %>" href='<%#Eval("homepage") %>' class="tooltip" target="_blank">
<div style="float:left;"><%#Eval("name") %>, <%#Eval("address") %>, <%#Eval("zip") %> <%#Eval("city") %> </div>
<div style="width:18px; float:left;">
<asp:Panel Width="18px" ID="pnlLink" runat="server" Visible='<%#Eval("IsUrl") %>'>
<a href='<%#Eval("homepage") %>' target="_blank">
<img src='/kort/www.png' />
</a>
</asp:Panel>
</div>
</a>
</td>
<td style="font-family:Verdana; font-size:11px; height: 18px;">Tlf. <%#Eval("phone") %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
I need to display the
<a id="tooltip_from_div<%#Eval("id") %>" .... >
</a>
tag with a span or div tag instead if the <%#Eval("IsUrl") %> is false – thus not displaying a link if there is no url string on the object.
How exactly do I go about this? Any help/hint is greatly appreciated! 🙂
All the best,
Bo
Best Answer
You could try by placing both
a
anddiv
tags, then set theVisible
property according to your condition.Simple, easy, smart