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..
Page lifecyle and clickevent
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Karthikeyan AnbarasanRank #71 · 25.5K reputationPosted Apr 8, 2011, 1:40 AM EDT
Mats A54 reputationPosted Apr 8, 2011, 2:11 AM EDT
Karthikeyan AnbarasanRank #71 · 25.5K reputationPosted Apr 8, 2011, 2:19 AM EDT