Image from sql database to gridview
Posted on 2011-02-21
I have a ms server 2008, and code my site in aspx C#.
I want to retrieve an image from my database, and i know it is corectly placed inside my db, because i can view the images in a test query.
I retrieve all my data to my GridView through a SQLDataSource.
I got 5 columns, but it is only the picture that won't show.
i tried a lot of solution in the gridview:
Boundfields, Templatefields and Imagefield.
and i tried to make my column a varbinary(max) and image.
I have even tried to make a picture in the string with ASCII:
SELECT '<asp:image runat="server" ImageURL="aspnet_Users.ComLogo" />' 'ComLogo' ,
I think the problem lies in the way i point to the data in my sql selection string, because when i open my site and view the source code, the html shows <img src="" />.
My last try was
<asp:TemplateField HeaderText="Wild logo">
<asp:Image ID="Image1" runat="server" ImageUrl='<% #bind("ComLogo") %>' />