Answered by:
Images Not Showing in ListView

Question
-
User1356352994 posted
Hello,
I have a ton of listviews where previously I was using a database with the absolute reference to where the image was located. The location of the image is stored in the database. In MY database the images pull up fine images/thumbs/something.jpg
in my ListView control, I used <asp:image ID="something" runat="server" imageURL='<%# Eval("ThumbImage") %>' />
But on the server the project is running on now, those images are like so in the database
images\thumbs\something.jpg it's machine reference. How do I get these to show up in my project?!
Friday, December 7, 2012 10:05 PM
Answers
-
User1356352994 posted
actually, I got the answer
<asp:image ID="something" runat="server" imageURL='<%#"~/Images/" + Eval("ThumbImage") %>' />
this turns all the \ slashes into / slashes. didn't matter which folder my images were in either there was two directories
images/
images/thumbs/
pull images from both.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, December 8, 2012 12:18 AM
All replies
-
User-1716253493 posted
try
<asp:image ID="something" runat="server" imageURL='<%# Eval("ThumbImage","http://yourapp/{0}) %>' />
Do you mean getting imageurl from server to your pc? Try above
<asp:image ID="something" runat="server" imageURL='<%# Eval("ThumbImage","~/{0}") %>' />
I am not sure what you mean, modify above format.
Friday, December 7, 2012 10:13 PM -
User1356352994 posted
Hi oned thanks for looking at this.
I tried this
<asp:image ID="something" runat="server" imageURL='<%# Eval("ThumbImage","~/{0}") %>' />
but the images still do not show.
on the database the reference path again is:
images\thumbs\myimage.jpg
The asp:Image control does not like the \ slashes.
Friday, December 7, 2012 10:35 PM -
User-1716253493 posted
I have similar url to a file pdf
http://domainname/abc\folder\filename.pdf
but when i download the file no problem. I am not sure the problem from the slash. Try open the image drirectly in address bar to make sure you can see it in browser.
If the slash is the real problem you can change your SELECT command to use REPLACE :
SELECT REPLACE([ThumbImage],'\','/') as NewTumbs, ....
<asp:image ID="something" runat="server" imageURL='<%# Eval("NewTumbs","~/{0}") %>' />
Friday, December 7, 2012 11:07 PM -
User1356352994 posted
actually, I got the answer
<asp:image ID="something" runat="server" imageURL='<%#"~/Images/" + Eval("ThumbImage") %>' />
this turns all the \ slashes into / slashes. didn't matter which folder my images were in either there was two directories
images/
images/thumbs/
pull images from both.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, December 8, 2012 12:18 AM -
User-1716253493 posted
You can also do like this
<asp:image ID="something" runat="server" imageURL='<%# Eval("ThumbImage","~/images/{0}") %>' />
Saturday, December 8, 2012 2:47 AM -
User1356352994 posted
No that does not work.
Saturday, December 8, 2012 10:27 AM