1
這裏是代碼。它沒有顯示任何編譯或運行時錯誤。我也調試,直到數據綁定工作正常。但是,然後也控制不顯示在網頁上!綁定中繼器到堆棧列表
Sample.aspx:
<body>
<form id="form1" runat="server">
<asp:PlaceHolder ID="_placeHolder1" runat="server">
</asp:PlaceHolder>
</form>
</body>
Sample.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;
}
是否有你爲什麼需要動態和不加中繼器在設計時特別的原因? Yup! –