I'm trying to create LinkButtons Dynamically and change their onclick event from the server side like this:
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...)
}
But my problem is that i'm getting an error on "pb.Click += new EventHandler(Method1);" saying: "No overload for 'Method1' matches delegate 'System.EventHandler'" I can't seem to find why it is not working...
Any help would be greatly appreciated!!!