Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I bind an ASP.NET Repeater Control to an IList<String>?

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?

like image 546
Nate Avatar asked Dec 17 '22 07:12

Nate


1 Answers

Try this:

<asp:Repeater ID="rptChecks" runat="server">
     <ItemTemplate>
          <input type="checkbox" id="<%# Container.DataItem %>"/>
     </ItemTemplate>
</asp:Repeater>
like image 169
Andrew Hare Avatar answered Dec 19 '22 20:12

Andrew Hare