I realize you can declaratively assign an event handler to a child control inside a formview by adding its attribute on the aspx page (i.e. onclick="Button_Click"), but if I wanted to do this programmatically, how would I go about it? That control isn't going to be found through FormView.FindControl in the Page's Init or Load events, so it can't be assigned in those stages. The DataBound event of the FormView will allow you to find the control, but is inappropriate, since that only happens once, and then the event won't always be bound, and it won't fire. I'm not asking because I can't get around it, I just wanted to know how it could be done.
Cheers.
You should use the FormView's ItemCreated Event. It occurs after all rows are created, but before the FormView is bound to data.
Look at this MSDN page for more information
in c# this is accomplished via:
this.btnProcess.Click += new EventHandler(btnProcess_Click);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With