Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1085
WebDropDown: programatically added templates (itemtemplate and headertemplate) lost on postback
posted

We are dynamically adding ItemTemplate and HeaderTemplate to WebDropDown at runtime, but when the page is posted back, the templates are lost.

If we re-add the templates anywhere in the page lifecycle after oninit, then the data is lost. If we do not re-add the templates, the data is not lost.

However, since the configuration for the templates is stored in viewstate and ensuretemplates is called during OnInit, we cannot use either OnInit or EnsureTemplates to configure the templates.

Moving the template definition into declarative markup is not an option because our customers are allowed to control the visibility, captions, and other information associated with the WebDropDowns.

Can someone please give us some guidance on how we can add these templates programatically and have them and the associated data survive postbacks?