我无法在循环中从 asp 页面 (aspx) 将变量传递给用户控件 (ascx)。
我想使用 foreach 循环递归迭代自定义控件(希望避免使用asp:Repeater,但如果它是唯一的解决方案,我愿意接受有关建议。
我使用了我知道的所有服务器内联标签,但结果要么得到完整
<%= stringvalue %>
到控件(意思是在接收控件中的参数的字符串变量中,我看到的是表达式而不是值)或者当我使用绑定标签时为空
<%# stringvalue %>
这是我在 aspx 文件中所做的:
<%foreach (string item in listItems)
{
tempItem = item;
%>
<uc:CustomControl runat="server" id="controlId" AutoPostback="true" parameterCustom='<%# Eval("tempItem")%>'/>
<%
}%>
在我的控制之下
public string parameterCustom {get;set;}
应该接收值