@kucheravy
Oh! I see what the problem is.
If you're calling the
ControlCollection.AddAt() method then you're probably dynamically adding controls to your page. You did not mention this fact in your explanation of the problem...in fact your example code doesn't show you dynamically adding the control at all.
The reason the ViewState isn't being remembered in your case is because of how the ASP Page Life Cycle works...
This is what's happening:
The web browser makes a request for the page.
The Page Init Event occurs and all of the Objects required to do page processing are created.
Right After the Page Init Event the ViewState of the controls are loaded.
If your dynamically creating controls in the Page Load (or after that in the life cycle) then the ViewState for the control is not loaded because the Object doesn't exist!
So, if you want the ViewState to load for dynamic controls, then you'll have to instantiate them (use the "new" statement) in the Page Init event. You also have to add them to their appropriate containers at this point too or you're going to experience a validation exception.