I have a usercontroll which accepts some parameter and I need to insert this usercontrol in repeater and pass a parameter from List<> to each one, I’m doing it like this:
<asp:Repeater ID="winnersRepeater" runat="server">
<ItemTemplate>
<uc:myControl ID="myControl" NodeId="<%# DataBinder.Eval(Container.DataItem,"Id")%>" runat="server" />
</ItemTemplate>
</asp:Repeater>
I do binding in PageLoad:
List<Winner> winners = new List<Winner>();
//...
winnersRepeater.DataSource = winners;
winnersRepeater.DataBind();
It doesn’t work, I’m getting Error creating usercontrol... The server tag is not well formed.
How can I do it? thanks
The trick here is with quotes – you are using double quotes both to open and close the NodeId property here, and to enclose the string in the expression. You should use single quotes in one place, and double in the other.