We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


If / Else Statement in ASP.NET

AlexPonnath asked
Medium Priority
Last Modified: 2008-03-10
I am using a repeater Control and would like to evaluate the date to diplay an image based on the
value of an field. But since this i guess has to happen in the actual ASP page not the code behind
i am having problems...
Below is my stab at it

If  <%# DataBinder.Eval(Container.DataItem, "direction")%> = "inbound" then
<img src="images/image3.gif" />
<img src="images/level3_group.gif" />
end if

Watch Question

you should use an IIF statement

<img src='<%# iif(DataBinder.Eval(Container.DataItem, "direction")= "inbound", "images/image3.gif", "images/level3_group.gif")%>' />

that would create an image and set its source to either image3 or level3_group depending if direction="inbound"

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
This should work also:
<% If  DataBinder.Eval(Container.DataItem, "direction") = "inbound" then  %>
<img src="images/image3.gif" />
<%Else %>
<img src="images/level3_group.gif" />
<%end if %>
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.