If / Else Statement in ASP.NET

Posted on 2006-04-05
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

Question by:AlexPonnath
    LVL 15

    Assisted Solution

    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"
    LVL 14

    Accepted Solution

    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 %>

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on could not pull conte…
    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now