views:

583

answers:

1

The code below works perfect for binding actual urls grabbed from the net. My issue is that it does not work for *.aspx urls that generate an image. If I go to the *.aspx page "~/UserPages/Photo/GetThumbnail.aspx?id=7", an image shows up just fine. However it does not work for the datalist. Any ideas why and how I can solve this issue. Thank you! The string array 'imageurls' consists of many *.aspx image urls.

<asp:DataList ID="dlImages" runat="server" 
    RepeatColumns="5" 
    RepeatDirection="Horizontal" 
    RepeatLayout="Flow">

    <ItemTemplate>
        <img src="<%# (string)Container.DataItem %>" />
    </ItemTemplate>

</asp:DataList>

Code behind

protected void BindImages(string[] imageurls)
{
    dlImages.DataSource = imageurls; 
    dlImages.DataBind();
}
+2  A: 

Try

<%# ResolveUrl((string)Container.DataItem) %>

SirDemon
amazing that did it! Thank you! what does that do?
It resolves a url string to an actual url within your web application. Since your path begin with ~ you obviously wanted the ApplicationPath, ResolveUrl does exactly that.
SirDemon
Great Thank You!