Author: airic82 | Posted on: 7/10/2008 5:44:14 PM | Views : 482

I'm creating an asp:Table dynamically and the last row contains a button. This is my code for the button:



Button button = new Button();

button.Text = "OK";

button.ID = "OkButton";

button.Click += new EventHandler(button_click);



The button is then added to the asp:Table.



Then later I have a standard button_click function defined.



The problem is that when you click the button, there is no effect. No attempt to reload anything. The code in button_click doesn't even get executed (I setup a breakpoint to check).



I think I know that the problem is that the EventHandler isn't assigned in the Page_Load method, but how can I define it there if the button doesn't exist at that point? I've been able to find info on how to dynamically add controls (as I'm doing), but nothing on dynamically causing them to fire events.



Any help you guys have ...

Go to the complete details ...