Repeater或者DataList中如果要使用Custom User Control可以使用如下方法。
<asp:Repeater ID="repeater1" runat="server">
<ItemTemplate>
<tr>
<td><uc1:mycontrol runat="server" id="mycontrol1" ProductID='<%# DataBinder.Eval(Container.DataItem, "Key") %>' /></td>
</tr>
</ItemTemplate>
</asp:Repeater>
注意,如果 '<%# ... %>' 没有用单引号而用双引号,服务器会发出The server tag is not well formed的错误。







注意,如果 '<%# ... %>' 没有用单引号而用双引号,服务器会发出The server tag is not well formed的错误。