Using an ASP.NET repeater with an array?

Rob Stevenson-Leggett picture Rob Stevenson-Leggett · Jan 28, 2009 · Viewed 10.8k times · Source

This may be a silly question but I was writing a quick test page and realised that I didn't know how to bind an array or ArrayList of strings, for example, to an ASP.NET Repeater.

I experimented a bit.

    <asp:Repeater ID="rptImages" runat="server">
        <HeaderTemplate>
            <h3>Items</h3>
        </HeaderTemplate>
        <ItemTemplate>
            <p style="background-color:Black;color:White"><%#Eval(Container.DataItem.ToString())%></p>
        </ItemTemplate>
        <FooterTemplate>
            <h4>End of Items</h4>
        </FooterTemplate>
    </asp:Repeater>

Am I being completely stupid? I've only really used it for collections of objects with properties.

Answer

Andreas Niedermair picture Andreas Niedermair · Jan 28, 2009

hoho ...

<%# Container.DataItem %>