Search code examples
asp.netrepeater

Adapting a jQuery slideshow to work with an ASP Repeater


I'm using a jquery slideshow and I want to fill in the pictures from a database. I'm trying to use an ASP repeater to create the images in a div with this code.

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="dsSelectedCategory" Visible="True">
        <ItemTemplate>
            <a><asp:Image ID="Image2" runat="server" ImageURL="~/img1/photos/<%#Eval("PictureFilePath") %>" class="slide" /></a>
        </ItemTemplate>
        </asp:Repeater>

I'm getting the error that the server tag is not well formed and I'm guessing it is this bit

ImageURL="~/img1/photos/<%#Eval("PictureFilePath") %>"

PictureFilePath is a field in the database that holds the filename and extension of the file. So I have to write out the path to the file then add on the name.


Solution

  • Try

    ImageURL='<%# "~/img1/photos/" + Eval("PictureFilePath") %>'