I have a composite control that contains a ListBox child control. On postback, the items for the ListBox disappear. I have a property for the ListBox that initializes it, and I add it to the controls collection in CreateChildControls. Am I doing something wrong? Do I need to be doing something else to properly handle the viewstate of this ListBox?
Be sure to add your control to the parent before you add listitems or databind. Otherwise, your composite control won't track viewstate on your ListBox's listitems.
Here's a more thorough explanation: http://scottonwriting.net/sowblog/posts/2129.aspx.
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