what is way to use asp:imagefield other than simple replacement

R

Ryan Liu

Hi,

<asp:imagefield dataimageurlfield="LastName"
dataimageurlformatstring="~\Images\{0}.jpg"
alternatetext="Employee Photo"
nulldisplaytext="No image on file."
headertext="Photo"
readonly="true"/>

Is the sample on MSDN doc.

But what about I need diffrent rules other than simple string replacement
{0}, e.g. use different images based on data field which type is an enum?
So a translation needed, how to do that declaratively?

I know I can accomplish same goal using <asp:TemplateField>, but just
thought there should be a way to make <asp:imagefield> more useful.

Thanks!
Ryan
 
G

Guest

Hi,

 <asp:imagefield dataimageurlfield="LastName"
            dataimageurlformatstring="~\Images\{0}.jpg"
            alternatetext="Employee Photo"
            nulldisplaytext="No image on file."
            headertext="Photo"
            readonly="true"/>

Is the sample on MSDN doc.

But what about I need diffrent rules other than simple string replacement
{0}, e.g.  use different images based on data field which type is an enum?
So a translation needed, how to do that declaratively?

I know I can accomplish same goal using <asp:TemplateField>,  but just
thought there should be a way to make <asp:imagefield> more useful.

Thanks!
Ryan

Ryan,

ImageField is used to show images using links from a data source. You
can change data source to return final ulrs, for example, for SQL
Server it could be something like this

SELECT photoid,
CASE
WHEN phototypeid = '1' THEN 'big1.gif'
WHEN phototypeid = '2' THEN 'big2.gif'
WHEN phototypeid = '3' THEN 'big3.gif'
AS photourl
.....

If you need other rules and you cannot change data source, then it
makes no big sense to use ImageField (e.g. use TemplateField
instead).

Hope this helps
 

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

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top