Mats A

Mats A

  • NA
  • 53
  • 24.7k

page lifecyle and clickevent

Apr 8 2011 2:40 AM
I have som buttons i add dynamically to my page. When clicked on the first time it works fine and the method is called, as I click on a different button after that I have to click twice to make the method call. Does anyone now why.

On page load (!Page.IsPostback) I build the table and the linkbuttons it contains and display it.

LinkButton btn = new LinkButton();
btn.Text = row.ItemArray[0].ToString();
btn.CommandName = "ID";
btn.CommandArgument = row.ItemArray[0].ToString();
btn.Command += new CommandEventHandler(test);

When a button is clicked the first time it works fine, when a second button is clicked nothings happens, it has to be clicked twice. Any ideas?

On (Page.isPostback) i recreate the table after it has been changed in the "test" method (that has been called by the command).

So why is the method not called as a button is clicked after the first click..

Answers (3)