I was building a new server control for my employer when I stumbled across this unexpected error:

"The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases."

This proved to be a misleading error. The problem occurred because I tried to modify the Control collection outside of the new server control's own collection. This could only be done when the Parent property had been set, which is never until the Init cycle. Effectively, modifying a parent's control collection is disallowed.

The solution to my problem was ensure that all dynamically added controls were added to the custom server control's collection only.

Happy Coding!