0

I want to show Images in my datalist. Image URLs are stored in my database. For some reason urls can't be retrived from my database.

Anyone knows what Am I missing? Here is my code.

 <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" RepeatColumns="3" Width="100%">

        <ItemTemplate>
            <asp:Image runat="server" ImageUrl="http://mywebsite.com/folder/{0}" Width="100%" />

        </ItemTemplate>

    </asp:DataList>


     <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
         SelectCommand="SELECT [url] FROM [MyDatabase]"></asp:SqlDataSource>
rootpanthera
  • 2,731
  • 10
  • 33
  • 65
  • are the images in same server ? – Raghubar Dec 13 '13 at 16:51
  • Yes. They are just in different folder. As final link I receive that kind of url. http://mywebsite.com/folder/%7B0%7D. I'm not that familiar with asp.net , so I would need some assistance :) – rootpanthera Dec 13 '13 at 16:52

1 Answers1

1

There is problem in binding image to image control. Try this.

<asp:Image runat="server" ImageUrl='<%# "http://mywebsite.com/folder/" + Eval("url") %>' Width="100%" />

Or

<asp:Image runat="server" ImageUrl='<%# "~/folder/" + Eval("url") %>' Width="100%" />
Raghubar
  • 2,768
  • 1
  • 21
  • 31