我正在尝试动态创建 LinkButtons 并从服务器端更改其 onclick 事件,如下所示:
for (int i = 1; i <= pagenum; i++)
{
LinkButton pb = new LinkButton();
pb.Text=i.ToString();
pb.CommandArgument=i.ToString();
pb.ID = "PageLink" + i.ToString()+",";
pb.Click += new EventHandler(Method1);
pb.Visible = true;
PagesDiv.Controls.Add(pb);
}
public void Method1(object sender, EventArgs e, int pagenum)
{
PagesDiv.Visible = true;
TableDiv.Visible = true;
localhost.StorageService w = new localhost.StorageService();
DataTable dt = w.GetItemsByCategory(pagenum, categoryname.ToString());
.................................(alot of code here...)
}
但我的问题是我在“pb.Click += new EventHandler(Method1);”上遇到错误 说:“'Method1'没有重载匹配委托'System.EventHandler'”我似乎无法找到它为什么不起作用......
任何帮助将不胜感激!!!