Question

I am using a Repeater and DataBinder.Eval to get the values from a code behind:

<asp:Repeater id="Repeater1" runat="server">
     <ItemTemplate>
        <ul data-role="listview" data-divider-theme="f" data-inset="true">
         <li data-theme="c">
          <%# DataBinder.Eval(Container.DataItem, "Email")%> 
         </li>
        </ul>
     </ItemTemplate>
</asp:Repeater>

Email returns true or false. If the value is true i want to show image_open.png and if it the value of Email is false than image_close.png

Is there something like:

<% if (DataBinder.Eval(Container.DataItem, "Email").Equals("true"))%>
   <img src="image_open.png" />
<% else %>
   <img src="image_close.png" /> 
Was it helpful?

Solution

You can make use of conditional operator:

<img src='<%# ((bool)Eval("Email")) ? "image_open.png" : "image_close.png" %>' />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top