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

2 posts, 0 answers
  1. Muhammad Rashed
    Muhammad Rashed avatar
    2 posts
    Member since:
    Dec 2014

    Posted 04 Aug 2015 Link to this post

     I Added the grid in the Sharepoint web part  , I did not add any code behind  , I just added to the aspx the following : 

    <telerik:RadGrid ID="RadGrid1" runat="server" >
     
    </telerik:RadGrid>

    The exception is:

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

     

    • [HttpException (0x80004005): The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.] System.Web.UI.ControlCollection.Add(Control child) +353 Telerik.Web.SkinRegistrar.RegisterCssReference(Page page, Type registerType, String url) +618 [HttpException (0x80004005): Please, see whether wrapping the code block, generating the exception, within RadCodeBlock resolves the error.] Telerik.Web.SkinRegistrar.RegisterCssReference(Page page, Type registerType, String url) +729 Telerik.Web.SkinRegistrar.RegisterCssReferences(ISkinnableControl control) +683 Telerik.Web.UI.RadGrid.ControlPreRender() +56 System.Web.UI.Control.PreRenderRecursiveInternal() +155 System.Web.UI.Control.PreRenderRecursiveInternal() +240 System.Web.UI.Control.PreRenderRecursiveInternal() +240 System.Web.UI.Control.PreRenderRecursiveInternal() +240 System.Web.UI.Control.PreRenderRecursiveInternal() +240 System.Web.UI.Control.PreRenderRecursiveInternal() +240 System.Web.UI.Control.PreRenderRecursiveInternal() +240 System.Web.UI.Control.PreRenderRecursiveInternal() +240 System.Web.UI.Control.PreRenderRecursiveInternal() +240 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4106

     

     

    Any suggestions ?

  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 06 Aug 2015 Link to this post

    Hello Muhammad,

    In order to fix the problem try moving the SPWebPartManager control in the MasterPage from the HEAD section into the BODY section of the html MasterPage.  

    This is what you need to move into the BODY:

            <!--MS:<SharePoint:AjaxDelta id="DeltaSPWebPartManager" runat="server">-->
                <!--MS:<WebPartPages:SPWebPartManager runat="server">-->
                <!--ME:</WebPartPages:SPWebPartManager>-->
            <!--ME:</SharePoint:AjaxDelta>-->


    Hope it helps.

    Regards,
    Maria Ilieva
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top