I made an account on this site so that I could post an answer to this posting "Why ViewState/ControlState Loaded After CreateChildCont rols" and for some reason that is beyond me I was not allowed to post a reply.
Anyway. If you wish to access the ViewState or ControlState in order to create controls dynamically in a CompositeContro l based upon the ViewState/ControlState data you cannot do so in CreateChildCont rols because ViewState and ControlState do not exist that that time.
However, what you can do is override the Load members for ViewState or ControlState and create your dynamic controls in there. e.g.
Where CreateMyDymaicC ontrols is a routine to create the dynamic controls and APropertyThatRe turnsDataFromCo ntrolState simply returns the business object that the dynamic controls will be based upon, taken from the ControlState.
Note, however, that this will only work if you setup ControlState for your control first, which can be found elsewhere on the net. I assume that the LoadViewState equivelent will work as well and won't need any special setup.
Sorry it is not a fully worked example, but I'm short of time.
Anyway. If you wish to access the ViewState or ControlState in order to create controls dynamically in a CompositeContro l based upon the ViewState/ControlState data you cannot do so in CreateChildCont rols because ViewState and ControlState do not exist that that time.
However, what you can do is override the Load members for ViewState or ControlState and create your dynamic controls in there. e.g.
Code:
protected override void LoadControlState(object savedState)
{
base.LoadControlState(savedState);
CreateMyDymaicControls(APropertyThatReturnsDataFromControlState);
}
Note, however, that this will only work if you setup ControlState for your control first, which can be found elsewhere on the net. I assume that the LoadViewState equivelent will work as well and won't need any special setup.
Sorry it is not a fully worked example, but I'm short of time.