I've a composite data-bound control which hosts a IBindableTemplate and dynamically loads a mark-up based on some condition into the control. Now, when these child controls are loaded into the composite control and postback is there, I lose viewstate of the child controls. Is there a way, I can save viewstate of the child-controls on the postback?
I also ref. to the Scott's explanation using http://scottonwriting.net/sowblog/posts/2129.aspx; but of no use.
Your theoretical code is almost near to my situation with only one major difference that I don't extend my template class from IBindable as such rather I provide the controls for the templates in the mark-up itself which is the requirement.
Scott also, makes it clear that if we add the controls to template like you have done
#region ITemplate Members
public void InstantiateIn(Control container)
{
Label label = new Label();
label.Text = "Label";
container.Controls.Add(label);
TextBox textbox = new TextBox();
container.Controls.Add(textbox);
}
#endregion
then the view-state will automatically be persisted on every postback. All I need is to allow my templates be instantiated in the mark-up and still persist viewstate on postback and allow me to fetch the status of control even if I used to re-initiate the template with some different data.