Creating Controls

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top