How to properly handle the state view of a child control in a composite control?

I have a composite control that contains a child ListBox control. Upon postback, items for the ListBox disappear. I have a property for the ListBox that initializes it, and I add it to the control collection in CreateChildControls. Am I doing something wrong? Do I need to do something else to properly handle the viewstate of this ListBox?

+3
source share
1 answer

Be sure to add your control to the parent before to add a list or data binding. Otherwise, your composite control will not track the list of views in the ListBox.

Here is a more detailed explanation: http://scottonwriting.net/sowblog/posts/2129.aspx .

+1
source

Source: https://habr.com/ru/post/1697946/


All Articles