Nate Bross
Well-known member
So I have a repeater control and everything displays as expected. My situation is that I have a field (websiteURL) that may or may not have data. If there is data I want to display the field in an HTML <img> and <a> tag. Like this:
The problem is that when there is no data in the field my image link is displayed, but links to a blank page.
Basically what I want to do is this:
The problem there is that I cannot use the #Container.DataItem in the context of an If statement.
What is the easiest way to use the repeater control and check to make sure data exists in that field before displaying it?
Code:
<a target="_blank"
href="<%#DataBinder.Eval(Container.DataItem, "LocURL")%>">
<img border="0" src="images\icons\Website-Icon.gif"
alt="<%#DataBinder.Eval(Container.DataItem, "LocURL")%>" /></a>
Basically what I want to do is this:
Code:
<%
If String.IsNullOrEmpty(#DataBinder.GetPropertyValue(Container.DataItem, "LocURL").ToString()) = True Then
%>
<a target="_blank"
href="<%#DataBinder.Eval(Container.DataItem, "LocURL")%>">
<img border="0" src="images\icons\Website-Icon.gif"
alt="<%#DataBinder.Eval(Container.DataItem, "LocURL")%>" /></a>
<%
End If
%>
What is the easiest way to use the repeater control and check to make sure data exists in that field before displaying it?