Hide Image Problem

S

Shapper

Hello,

I have an ASP:Datagrid where in each record I display an image.
The image I display can be one of two depending of the value of the
field "Level" of that record.

So for each record:
If level > 5 Then "images/high.gif" should be used.
Else "images/low.gif" should be used.

I have been trying with the HTML img tag and with the ASP:Image but
until now I wasn't able to do it.

For example, here it is the code I used for the HTML img tag:

<img src='<%# "images/" & If(DataBinder.Eval(Container.DataItem, "
level") > 5, "high.jpg", " low.gif") %>' />

Any idea how to solve this?

And should I use HTML img tag or ASP:Image?

Thank You For Your Help,
Miguel
 
E

Eliyahu Goldin

Try <img src='<%# GetImageSrc (DataBinder.Eval(Container.DataItem, "
level")) %>' />, where GetImageSrc is a method returning the right path
depending on the level value.

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top