Hi,
in an iteration, I create a LinkButton, add attributes to it, and finally add this LinkButton to the Form Controls.
That is fine, what is not is adding the Command Event. Here is my code
for (int i = 1; i % 6 != 0; i++)
{
if (Convert.ToInt32(Session["CurPage"]) != MyPgd.PageCount - 1)
{
LinkButton NewButton = new LinkButton();
NewButton.CommandName = "PageNo";
NewButton.CommandArgument = (Convert.ToInt32(Session["CurPage"])+i).ToString();
NewButton.Command +=new CommandEventHandler(NewButton_Command);
NewButton.Text = (Convert.ToInt32(Session["CurPage"]) + i).ToString();
Nav.Controls.Add(NewButton);
}
}
}
void NewButton_Command(object sender, CommandEventArgs e)
{
//throw new Exception("The method or operation is not implemented.");
Response.Write(e.CommandArgument.ToString());
//SetPage(Convert.ToInt32(e.CommandArgument.ToString()));
}
It writes nothing on the page, it is not firing.
Thanks in advance
Andrew
Additionallt it appears that
NewButton.CommandArgument = (Convert.ToInt32(Session["
supplies only a number without a link. supply a link also