in my asp.net mark up I have a foreach loop that iterates through a simple list. In this foreach loop I am adding a new user control and attempting to pass in the value from the loop. However, this value just wont budge and get inside that damn control! Anyone have any suggestions?
<%foreach (userInfo i in this.items)
{ %>
<uc1:ItemControl ID="ItemControl" runat="server" UserID='<%#Eval("userID") %>'/>
<%} %>
userID is a public property in the control, when it goes to set, the value is just literally : <%#Eval(“userID”) %>. I’ve tried #Bind and =Value but nothing seems to work.
Any help would be appreciated!
Looks like the perfect use case for a repeater:
You can databind your list (
this.items) to the repeater and in the code behind, in theDataBindevent set theUserIDproperty of theItemControlcontrol.The reason your approach will not work is that IDs have to be unique in a page.