Display image in gridview in asp.net

I am not sure what I am doing wrong. I am trying to display the images on the page, it will display the url but not the image. I tried both as a template field and also as an imagefield. With Firebug I can see the value of the image source.

aspx page:

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ImageID" DataSourceID="Images">
        <asp:BoundField DataField="ImageID" HeaderText="ImageID" InsertVisible="False" ReadOnly="True" SortExpression="ImageID" />
        <asp:BoundField DataField="InciID" HeaderText="InciID" SortExpression="InciID" />
        <asp:TemplateField HeaderText="Imagepath" SortExpression="Imagepath">
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Imagepath") %>'></asp:TextBox>
                <asp:image runat="server" ID="Label1" ImageUrl='<%# Bind("Imagepath") %>'></asp:image>
        <asp:BoundField DataField="ImageDescription" HeaderText="ImageDescription" SortExpression="ImageDescription" />
        <asp:BoundField DataField="Category" HeaderText="Category" SortExpression="Category" />
        <asp:ImageField DataImageUrlField="Imagepath">
            <ControlStyle Height="100px" Width="100px" />

Source code of the webpage from Firebug:

<td><img id="ctl00_ContentPlaceHolder1_GridView1_ctl15_Label1" src="images\curiouskids.jpg"></td>
<td><img style="height:100px;width:100px;" src="images\curiouskids.jpg"></td>


All of your slashes should be forward slashes for URLs.


I agree with Dave and Praveen.

slashes need to be forward slashes and you should try to prepend with ~/.

Thank you guys. I took your suggestion and modified it as written in the code below. Now I have a thumbnail of 100x100 and underneath that I have the text "Enlarged View" and clicking on this will open the full image in a new window. I added tilda and front slash in the code here and removed it from code behind upload.

           <asp:TextBox ID="TextBox2" runat="server" Text='<%# Eval("Imagepath") %>'></asp:TextBox>
            <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("Imagepath", "~/images/{0}") %>' Width="150px" Height="150px" /><br />
             <asp:HyperLink ID="HyperLink1" runat="server" Text="Enlarged view" Target="_blank"  NavigateUrl='<%# String.Format("~/images/{0}", Eval("Imagepath"))%>' />

Need Your Help

Can't add Preference in ICS

android android-4.0-ice-cream-sandwich preferences

How to add Preference in ICS using addPreferencesFromResource()?

Efficient PHP programming using exec

php linux design-patterns shell

I writing a PHP script program under Linux. In the script, I need call many other system tools/programs using exec to achieve some goals. I know that whenever I run a shell script in terminals, a new