views:

691

answers:

2

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.

+4  A: 

hoho ...

<%# Container.DataItem %>
Andreas Niedermair
Yup just spotted it, thankyou!
Rob Stevenson-Leggett
A: 

another question on this though...

say I'm using a template column in my griview that receives an array from the datasource in the form "xyz, 0", i.e., a string that should populate a label and a checkbox

How would I split that out to each of the controls?

This should really be a seperate question... something like: Container.DataItem.ToString().Split(',')[0] should do the trick
Rob Stevenson-Leggett