M
Mike Towle
Trying to create controls in a button.click event, not the Page_Init event. All examples of code I have found so far creates the controls and binds them to their container (form, placeholder, etc) in the Page_Init event. But if I try to create and bind a control in the button.click event, when the page refreshes I cannot remove / destroy the control. And if I reuse a dropdownlist control that was dynamically created in the button.click event then I cannot clear the list of items at all either. All I can do is add to the items collection. Cannot destroy the control and start over or clear the list of items. I am creating different controls based on values in a database. The button.click event destroys any previously created controls, fetches the next record in the database, creates the control based on the values in the database, binds it to the form or placeholder, and sets the properties of the control. Another issue is that if I dynamically create a control in the button.click event and bind it to a container such as a form or placeholder then if I query the container's controls.count method then the count has not changed!