views:

658

answers:

1

I've never had to do this, but I'm binding a repeater to a generic list of Strings, and I'm not sure of the correct syntax.

If I was binding to an IList and myType had a property LayerName I'd use this:

<asp:Repeater ID="rptChecks" runat="server">
     <ItemTemplate>
          <input type="checkbox" id="<%#Eval("LayerName") %>"/>
     </ItemTemplate>
</asp:Repeater>

How can I do this when I'm only binding to a String which does not have any properties to use?

+10  A: 

Try this:

<asp:Repeater ID="rptChecks" runat="server">
     <ItemTemplate>
          <input type="checkbox" id="<%# Container.DataItem %>"/>
     </ItemTemplate>
</asp:Repeater>
Andrew Hare
+1 bang on right!! It used to be necessary to do it this and a few other variations before ASP.net 2
Perpetualcoder