我正在尝试使用创建表的中继器来实现分页。我遇到的问题是我在 tr 中添加了按钮,但是当我单击它们时,如果我在它们的单击处理程序中放置一个断点,则没有任何反应。
创建按钮
private void CreatePaging(PlaceHolder literal)
{
int numPage = (totalItems / ITEMS_PER_PAGE);
if (totalItems % ITEMS_PER_PAGE > 0) numPage++;
literal.Controls.Add(CreateButton("<<", "b"));
for (int i = 0; i < numPage; i++) {
if (currentPageIndex == i)
{
Label lbl = new Label();
literal.Controls.Add(lbl);
lbl.Text = " " + (i + 1).ToString() + " ";
}
else {
literal.Controls.Add(CreateButton((i+1).ToString(), (i+1).ToString()));
}
}
literal.Controls.Add(CreateButton(">>", "f"));
}
LinkButton CreateButton(string title, string index) {
LinkButton lnk = new LinkButton();
lnk.ID = index.ToString();
lnk.Text = title;
lnk.CommandArgument = index.ToString();
lnk.Click += new EventHandler(PageBtnClicked);
return lnk;
}