Image URL Cannot Retrieve Image Path from Data Source using Eval command

Hi guys.

Situation: I want to retrieve images reading the path of the image on a database and then put on the propertie ImageUrl of an Image control.


what i´m try to do is this:

<asp:Image ID="Image2" ImageUrl='<%# Eval("PictureURL","~/MatchImages/{0}") %>' runat="server" />

 when I run this code does not appear any image.


but if i do this:

<asp:Image ID="Image1" ImageUrl="~/MatchImages/aaronson.jpg" runat="server" /> the image appears.


Trying to insert a DataList the path of the Image appears on my browser

<asp:DataList ID="DataList1" runat="server" DataKeyField="PictureID" DataSourceID="SqlDataSource1">


<br />


<asp:Label ID="PictureURLLabel" runat="server" Text='<%# Eval("PictureURL") %>'></asp:Label><br />

<br />




Question: Can you help me understand i the image is not displayed?


Thanks in advance.



5/17/2008 10:30:16 AM 91979 articles. 4 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 43

The Eval method you are using expects PictureURL to be a Property of the page. It will not work for binding to multiple items in your database.

The DataList control binds to a DataSource so the Eval method will look for the PictureURL field of the DataItem in your datasource.

Using the DataList example above you could do this:


<asp:DataList ID="DataList1" runat="server" DataKeyField="PictureID" DataSourceID="SqlDataSource1">


<br />


<asp:Image ID="Image1" ImageUrl='<%# Eval("PictureURL") %>' runat="server" />

<br />





or you could set up a property in your code-behind to supply the url to your first example.

public string PictureUrl {
  get {
    //logic to return picture URL

Although this way I'd only recommend using for a single instance of an image.

Remember: mark posts that helped you as the answer to aid future readers

Why UpdatePanels Are Dangerous
Why You Should Not Place Your Whole Site In An UpdatePanel
5/17/2008 5:59:51 PM

 Hi, Please try this

<asp:Image ID="Image2" ImageUrl='<%# Eval("PictureURL","MatchImages/{0}") %>' runat="server" />

I have tried the same with datalist, giving path from root directory ~/, does not work for me.

Hope this would work for you as well.


5/18/2008 2:43:07 AM


Are you sure that Eval("PictureURL") is like "aaronson.jpg"? Maybe it is just "aaronson".

You can check the source code in browser, and check if the image path in HTML source code after running is correct.

Hope it helps.


Vince Xu
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
5/20/2008 7:34:17 AM

Similar Artilces:

Save Image Path into Database, Retrieve Image Path by Particular Image ID and Display Image through Gridview
Hi All, Currently, I have a file upload control in my aspx page to allow user to upload images. When the user clicks the SAVE button, the image will be saved in a particular folder named 'PMap' that located within the website. What I am trying to do here is to direct all uploaded images into a common image folder (in this case 'PMap') and then, retrieve the images and displayed it through a Gridview according to its respective image id. I have managed to store all uploaded images into a common image folder, PMap. However, I hope advice can be given on my following pro...

Storing images in SQL database vs storing images in seperate folder and using URL image path
Hi allCan you store images in a sql database and if so, does it store the images as an image file or does it store it in a binary format reducing the size of the image. If it can be stored in an sql database as a image or a binary format what are the advantages/disadvantages or is it better to store the url in the database and then bind the image holder to the url link in the database. Hi, These two ways are both ok. My suggestion is to store images into sql database if there are no much more images, otherwise, it's better store them into file system because you can store them no mat...

How to retrieve path of an image which is stored as image data in database.
Hi there, Is there anyone who can solve my problem? I need to use SlideshowExtender for photo album. As all know, to achieve this, there is a class called "Slide" in "AjaxControlToolkit" namespace, and "Slide" class takes (imagePath As String, name As String, description As String). I am uploading images as a binary data type in database and i am able to achieve those images as image object. Now my problem is how to pass "imagePath" in "Slide" class. Can anyone help?  Thanks in advance - Prachi Friend, I would recommend yo...

Adding images in crystal reports using URL path of the image
Hi... How to add images, whose URL path is stored in database..something like (http://<serverIP>/pictures/wqwq.jpg) to crystal report... Please help   You can try visiting the following URLs:  I hope it helps.  Microsoft ASP.NET Enthusiast  hello ankit_jedi try this wayi ...

How to show image when we choose the image path using Fileupload using javascript
Hello Mate,I have a file upload control and i have a image control. if i choose the image path by clicking "Browse" button from the file upload , i have to show that image in the image control and this should be done by javascript, i have to validate for only image files while setting the image url to the image control currently my code is  function setimage(obj) {var image=document.getElementById ('Image1');  document.getElementById('Image1').src= obj.value; } <asp:FileUpload Width="200px" onchange="setimage(this);" ID=&quo...

How to Insert Image Url and Display the Image of that Image Url in the Grid View?
Any one can help me out about this- How to Insert Image Url and Display the Image of that Image Url in the Grid View Hi You can add HyperLink control to Gridview by setting its ImageUrl and NavigationUrl property Please refer example. <asp:HyperLink ID="HyperLink1" ImageUrl="images/image.gif" NavigateUrl="PageUrl.aspx" runat="server">HyperLink</asp:HyperLink>Please mark the post as answered if it helped you. Hi sandynaidu, This is easy to solve. Assuming that your GridView's ID is gv, that you want to have the image in your firs...

How to use an alternate image url if first image url can't be found
 Hello,I have a product detail page that pulls in a picture and some product details for a product when a user clicks a link in a gridview on another page.  The image files have names like: 1000k.jpg, but for some products the img file names are like: 1000w.jpg.  I want to be able to look for the "w" version if the "k" version can't be found.  I was able to solve a similar problem with product detail text files by using "error catching", but since the inability to find an image url doesn't raise an error, I'm at a loss as to how I...

Image Url
 I have a Image control which will display the selected image from the client File system(ie : the image is not been uploaded untill the user press save button)When the user browers a image which contains space in the image path(eg:C:\Documents and Settings\user\Desktop1.jpg), then that image is not been displayed <script runat="server"> protected void btnShowP_Click(object sender, EventArgs e) { Image1.ImageUrl = FileUpload1.PostedFile.FileName; } protected void btnSave_Click(object sender, EventArgs e) { Sys...

BUG: Image Controls in UpdateProgess Control: Can not use FindControl() methods to get Image
There is a single UpdateProgress control on the page. as such: <ajax:UpdateProgress  ID="UpdateProgress1" runat="server"   DisplayAfter="100" >         <ProgressTemplate>                <div style="border:2px solid #0099FF; background-color:#EFEFEF; padding:10px; width:200px; height:20px;">               Updating Panel            </div&...

Can I display an image without getting the image from a URL?
From what I've read, it appears you can take an image and create a thumbnail of it with the result being a type 'image'. However, a search of dozens of sites suggests (hopefully this isn't true) that one always uses the URL of an image file to get the image to a control--meaning I can't just use the image created from the workup of an original image. I'm posting the demo code I'm trying, hoping that maybe I'm missing one or two easy steps.    Dim FullImage As Image = Image.FromFile("C:\temp\Picture1.jpg") ...

Display image on page using full path of image
I am attempting to display an image in my Repeater control.  At run-time, I have only the full path of the image. (eg: c:\somedir\somedir\imagename.gif) The images are not located in the directory that the web application is running in. Is it possible to display the image?-Craig - Taking Fantasy Football to School Yes you can. i.e.  "Repeater1" runat="server" DataSourceID="SqlDataSource1"> "Image" runat="server" ImageUrl="C:/myImage.gif" /> <%# Eval("fldTitle") %> ...

Retrieve image path from access db to view image
i store a pic in a folder in C drive, and create a access mdb file with a ID as string, and a ImagePath as string.ID=abc;ImagePath=C:\\abc.jpgand now my problem is how to retrieve the image from the folder using the ImagePath and display it using datagrid.can someone show me the code here for this part????   Hi Jazkyching Indeed you need from ImageUrl not from the ImagePath Try the following snippet code    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" ... problem: i can not view image data for the rest of my table rows except the image for the first row but i can read all the other non image fields for all rows.
Hi i have a table with the following fields imgdata........image imgtitle.........varchar(max) imgType........varchar(max) imgLength.....bigint i have no problem with uploading the image but viewing the uploaded image(s) in a gridview has caused me great pain. The probelm is i have two pages. page1 grabs the image to display and page2 has a gridview that displays the grabed image. I wanted to have an sql statement like SELECT * FROM mytable WHERE incident_id=someValue. IF i have 5 records in this table and i view page2 ...

image and image
// create an image object, using the filename we just retrieved System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(file)); // create the actual thumbnail imageSystem.Drawing.Image thumbnailImage = image.GetThumbnailImage(64, 64, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);   now my question is how to display this image in my image1 control in (version 1.1) the below line of code is not working.  Image1.ImageUrl=thumbnailImage.ToString();Mark As Answer If my reply helped you. Hi, you can save t...

Web resources about - Image URL Cannot Retrieve Image Path from Data Source using Eval command -

Facebook Developers Can Retrieve Users’ Profile Pictures In Different Sizes
Facebook introduced a way for developers to retrieve users’ profile pictures for use within their applications in different sizes, rather than ...

Winston retrieves the news
... food and losing weight. Three months ago, we were told he had lymphosarcoma of the GI tract. On March 10, 2008, Winston was called to go retrieve ...

Gizzard uses a rope to retrieve a submerged gift, 10 second retrieval from noticing the rope - YouTube ...
This is the second attempt, and the second occurrence he has ever seen this contraption. Without the rope, he would probably drown to retrieve ...

Dutch backpacker paid $5 an hour to retrieve golf balls from lakes
A Dutch backpacker claims he was paid as little as $5 an hour to wade through murky ponds and lakes retrieving thousands of lost golf balls. ...

People Are Willing To Go To Extreme Lengths To Retrieve Their Stolen Smartphones
People are willing to pay a ton of money and potentially put themselves in danger to retrieve their stolen smartphones, a new survey has found. ...

Police officer shot at 'very large' shark to retrieve body of swimmer
A policeman who shot a shark in a bid to retrieve the body of a swimmer it had killed says his first bullets disintegrated as they hit the water ...

Divers retrieve body from NSW floodwaters
A woman's body has been retrieved from a submerged car in a creek in Maitland.

Tourist plunges to death from Potts Point rooftop park trying to retrieve football: police
A French tourist who fell to his death from a rooftop park in Potts Point in inner Sydney was attempting to retrieve a football that had gone ...

The art of war: Quest to retrieve what Nazis stole
Susan Fisher Sullam tells of learning her father was a wartime treasure hunter, tracking down what the Nazis had plundered from Holocaust victims. ...

Investigators retrieve more human remains at MH17 crash site in eastern Ukraine but wreckage cannot yet ...
Dutch forensic experts recover further human remains at the crash site of downed flight MH17.

Resources last updated: 11/24/2015 4:02:07 PM