这是代码。它没有显示任何编译或运行时错误。然后我也进行了调试,直到数据绑定工作正常。但是网页中也没有显示控件!
示例.aspx:
<body>
<form id="form1" runat="server">
<asp:PlaceHolder ID="_placeHolder1" runat="server">
</asp:PlaceHolder>
</form>
</body>
示例.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
_placeHolder1.Controls.Add(CreateReapeater());
}
private Control CreateReapeater()
{
Repeater _repeater1 = new Repeater();
Stack _stack1 = new Stack();
for (int i = 0; i < 7; i++)
{
_stack1.Push(i);
}
_repeater1.DataSource = _stack1;
_repeater1.DataBind();
return _repeater1;
}