Click here to Skip to main content
Sign Up to vote bad
good
See more: ASP:NET
i have grid view and in the template field of grid view i have image control
and this control bind from sql server database 2005
i retrieve this image from sql server database 2005 in the table image column have only image name insert not image url
<asp:TemplateField>

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


 

but image not retrieve by image control
Posted 11 Nov '12 - 19:49
M@anish1.3K
Edited 11 Nov '12 - 20:16

Comments
Sergey Alexandrovich Kryukov - 12 Nov '12 - 3:34
Not clear. What do your try to achieve? --SA

2 solutions

Dude,as per my understanding..only the image name is stored in the database but the imageurl.So only with the image name you cannot get the image from database.Also bind the image path to the Imageurl as shown below.
 
 ImageUrl='<%# String.Format("~/path/to/image/" + Eval("product_img")) %>'
 

Replace ~/path/to/image/ with the path where the images are stored.
 

---Prathap.
  Permalink  
Comments
Mas11 - 12 Nov '12 - 6:33
Good Answer !
it is recommended to use HttpHandler to retrieve image. Take a look at the below article. It would explain in detail about fetching an image from database and displaying it in a gridview.
How to display and upload image in GridView
Display Images from database in ASP.NET GridView using HttpHandler
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 483
1 Arun Vasu 315
2 OriginalGriff 250
3 Maciej Los 218
4 Aarti Meswania 170
0 Sergey Alexandrovich Kryukov 9,680
1 OriginalGriff 7,539
2 CPallini 4,018
3 Rohan Leuva 3,362
4 Maciej Los 2,951


Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 12 Nov 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid