Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Creating Controls

Reply
Thread Tools

Creating Controls

 
 
Mike Towle
Guest
Posts: n/a
 
      04-14-2004
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!
 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      04-16-2004
cross posts will least likely end up with answered questions.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/27cok
"Mike Towle" <> wrote in message
news:C46C4561-A933-4AF0-A229-...
> 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!



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Controls.Count, Controls.IsSynchronized, and Controls.SyncRoot Nathan Sokalski ASP .Net 4 09-05-2007 03:27 AM
creating dynamic controls out of static controls Tarscher ASP .Net 9 02-13-2007 02:33 PM
"Error Creating Control" when creating a custom control (Design Time). Can't see tooltip message. Ravi Ambros Wallau ASP .Net Web Controls 0 06-01-2005 02:36 PM
"Error Creating Control" when creating a custom control (Design Time). Can't see tooltip message. Ravi Ambros Wallau ASP .Net 0 06-01-2005 02:36 PM
Creating Form Controls at Run-Time Tarang Deshpande ASP .Net 6 07-25-2003 06:07 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57