This topic is locked
[SOLVED]

 Adding Image to List

2/25/2016 8:53:58 PM
ASPRunner.NET General questions
R
raymueller authorDevClub member

I want to add an image to a list view that corresponds to how a project is trending. The options are at threshold, above threshold and below threshold. These values are maintained in a table that are assigned an Trend ID of 1, 2 and 3 respectively.
Based on the value of the TrendID, I would like to display one of three images
What would be the best method to implement this functionality?
Thank you

Ray

Sergey Kornilov admin 2/25/2016

I would suggest using 'View as' Custom for this purpose:

http://xlinesoft.com/asprunnernet/docs/_view_as__settings_custom.htm
Your code will be something like this:

if (Convert.ToInt32(data["SomeField])<10)

value="<img src='images/red.png'>";

else if (Convert.ToInt32(data["SomeField])<100)

value="<img src='images/yellow.png'>";

else

value="<img src='images/green.png'>";
R
raymueller authorDevClub member 2/26/2016

Sergey - Thank you. I will try this later - this is what I was looking for.

Thanks

Ray



I would suggest using 'View as' Custom for this purpose:

http://xlinesoft.com/asprunnernet/docs/_view_as__settings_custom.htm
Your code will be something like this:

if (Convert.ToInt32(data["SomeField])<10)

value="<img src='images/red.png'>";

else if (Convert.ToInt32(data["SomeField])<100)

value="<img src='images/yellow.png'>";

else

value="<img src='images/green.png'>";


R
raymueller authorDevClub member 2/26/2016

The solution works great at least when the application is initially launched.
The code is nearly identical

if ((data["obj_TrendFK"])==1)

value="<img src='images/ArrowRedS.png'>";

else if ((data["obj_TrendFK"])==2)

value="<img src='images/ArrowGreenS.png'>";

else

value="<img src='images/ArrowRedS.png'>";
When I initially launch the application, the images are displayed. The location of the graphics according to the browser is https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=78885&image=1&table=forumreplies.
When I have the application go to another function like Add page and come back, the images are not displayed. The location for the images is now https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=78885&image=2&table=forumreplies.
Somehow dbo_Objectives (a table in the solution) is being appended to the URL.
What did I miss?
Many thanks

Ray