Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8966841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:06:34+00:00 2026-06-15T17:06:34+00:00

I have a ASP.NET Application with a ListView. The ListView get Datafrom a DataTable

  • 0

I have a ASP.NET Application with a ListView. The ListView get Datafrom a DataTable and I want if my ListView builting the itemtemplate that I have a if clause for change a image inside.

ForExample:

My DataTable have a Column with name Enable. This can have two Values. The first Value is 0 and the second 1. If in my Columns is the Value 0 I want the a.png and if I have 1 a other image in my asp:image control (in my List View).

Here is my aspx site:

…

   <ItemTemplate>
        <tr onmouseover="this.style.backgroundColor='#87CEFA'"
        onmouseout="this.style.backgroundColor='#ffffff'">
            <td align="left"><span class="spanpading"><asp:Label ID="lblname" Text='<%# Eval("NAME") %>' runat="server"  /></span></td>
            <td align="left"><span class="spanpading"><asp:Label ID="lblcompany" Text='<%# Eval("COMPANY") %>' runat="server"  /></span></td>
            <td align="left"><span class="spanpading"><asp:Label ID="lblVon" Text='<%# Eval("TIMEFROM") %>' runat="server"  /></span></td>
            <td align="left"><span class="spanpading"><asp:Label ID="lblBis" Text='<%# Eval("TIMETO") %>' runat="server"  /></span></td>
            <td align="left"><span class="spanpading"><asp:Label ID="lblErsteller" Text='<%# Eval("CREATOR") %>' runat="server"  /></span></td>
            <td align="left"><asp:ImageButton ID="imgDelete" runat="server" ToolTip="löschen" ImageUrl="images/delete.gif" CommandName="DeleteClick" CommandArgument='<%# Container.DataItemIndex %>' /></td>
            <td align="left"><asp:ImageButton ID="imgUpdate" runat="server" ToolTip="ändern" ImageUrl="images/edit.gif" CommandName="UpdateClick" CommandArgument='<%# Container.DataItemIndex %>' /></td>
            <td align="left"><asp:ImageButton ID="imgEmail" runat="server" ToolTip="Zugangsdaten senden" ImageUrl="images/send.gif" CommandName="SendClick" CommandArgument='<%# Container.DataItemIndex %>' /></td>
           <% if ()
              { %>

             <td align="left"><asp:Image ID="imgActive" runat="server" ToolTip="Aktiv" Width="25px" Height="25px" ImageUrl="images/yes.gif"/></td>

             <% } %>

            <td><asp:Label ID="lblID" runat="server" Text='<%# Eval("ID") %>' Visible="False" ></asp:Label></td>
        </tr>
    </ItemTemplate>

…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:06:35+00:00Added an answer on June 15, 2026 at 5:06 pm

    You could use a block element like e.g. <span>, make it run at server and toggle its visibility, based on a data binding element.

    E.g.:

    <span runat="server" Visible='<%# Eval("IsConditionTrue") %>'>
        <!-- ... Place your conditionally visible tags here inside ... -->
    </span>
    

    If you cannot evaluate to a single condition, you could also use a more complex statement like e.g.

    <span runat="server" 
          Visible='<%# (int)Eval("SomeValue")==1 && (bool)Eval("SomeOtherValue") %>'>
        <!-- ... Place your conditionally visible tags here inside ... -->
    </span>
    

    Finally to get to your concrete example, I think you could do something like:

    <span runat="server" Visible='<%# (int)Eval("Enable")==1 %>'>
        <asp:Image ImageUrl="images/yes.gif" />
    </span>
    <span runat="server" Visible='<%# (int)Eval("Enable")!=1 %>'>
        <asp:Image ImageUrl="images/no.gif" />
    </span>
    

    Of course, Mhd. Yasseen’s answer seems to be the shortest for your case:

    <asp:Image ImageUrl='<%# (int)Eval("Enable")==1 ? "yes.gif" : "no.gif" %>' />
    

    Please note that you have to add additional attributes like runat="server" to your Image tag, just as in your original question. I’ve omitted them for readability in my code above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET application with a ListView . I get data from Active
I have asp.net mvc application, that uses razor view engine. I want to send
I have an ASP.NET application that is hosted in timezone A and is being
I have an ASP.NET application that uses a custom .NET library (a .DLL file).
ASP.NET application, VB or C# doesn't matter. I have Listview which databound to Dataset
I have asp.net application that use forms authentication to control access. Let's imagine we
I have ASP.NET MVC application that has list with jQuery Selectable list. My problem
I have an asp.net application that requires some editing of the machine.config file in
I have an ASP.NET Dynamic Data application that includes two tables, Departments and KPI's
I have a ASP.NET application that we've written our own logging module for. My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.