Column Reordering: "Control collection cannot be modified..." error

7 posts, 0 answers
  1. Massimiliano
    Massimiliano avatar
    184 posts
    Member since:
    Oct 2012

    Posted 13 Jul 2013 Link to this post

    I receive this error while trying to drag to reorder columns in RadGrid + NeedDataSource scenario.
    The grid is all built inside aspx page.
    In code behind I only use NeedDataSource and ItemDataBound to show some boolean columns as formatted text instead of checboxes.

    The error is:

    Server Error in '/' Application.
     
    The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.
     
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
     
    Exception Details: System.Web.HttpException: The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.
     
    Source Error:
     
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
     
    Stack Trace:
     
     
    [HttpException (0x80004005): The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.]
       System.Web.UI.ControlCollection.RemoveAt(Int32 index) +12539142
       Telerik.Web.UI.GridBatchEditingHelper.CreateColumnEditorsPanel() +314
       Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +1632
       Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +1116
       System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +95
       System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +222
       Telerik.Web.UI.GridTableView.PerformSelect() +244
       Telerik.Web.UI.GridTableView.DataBind() +441
       Telerik.Web.UI.GridTableView.OnPreRender(EventArgs e) +53
       System.Web.UI.Control.PreRenderRecursiveInternal() +113
       System.Web.UI.Control.PreRenderRecursiveInternal() +222
       System.Web.UI.Control.PreRenderRecursiveInternal() +222
       System.Web.UI.Control.PreRenderRecursiveInternal() +222
       System.Web.UI.Control.PreRenderRecursiveInternal() +222
       System.Web.UI.Control.PreRenderRecursiveInternal() +222
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4297


    and

    Stack Trace:
     
    System.Web.HttpUnhandledException (0x80004005): Generata eccezione di tipo 'System.Web.HttpUnhandledException'. ---> System.Web.HttpException (0x80004005): The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.
       in System.Web.UI.ControlCollection.RemoveAt(Int32 index)
       in Telerik.Web.UI.GridBatchEditingHelper.CreateColumnEditorsPanel()
       in Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource)
       in Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource)
       in System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data)
       in System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data)
       in Telerik.Web.UI.GridTableView.PerformSelect()
       in Telerik.Web.UI.GridTableView.DataBind()
       in Telerik.Web.UI.GridTableView.OnPreRender(EventArgs e)
       in System.Web.UI.Control.PreRenderRecursiveInternal()
       in System.Web.UI.Control.PreRenderRecursiveInternal()
       in System.Web.UI.Control.PreRenderRecursiveInternal()
       in System.Web.UI.Control.PreRenderRecursiveInternal()
       in System.Web.UI.Control.PreRenderRecursiveInternal()
       in System.Web.UI.Control.PreRenderRecursiveInternal()
       in System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       in System.Web.UI.Page.HandleError(Exception e)
       in System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       in System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       in System.Web.UI.Page.ProcessRequest()
       in System.Web.UI.Page.ProcessRequest(HttpContext context)
       in ASP.admin_users_users_aspx.ProcessRequest(HttpContext context)
       in System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       in System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
     
    Exception Data (0 items):
     
     
     
    Base Exception Data (0 items):
  2. Andrey
    Admin
    Andrey avatar
    836 posts

    Posted 16 Jul 2013 Link to this post

    Hello,

    If you want to modify the structure of RadGrid on postback please check this help article. If you want to define dynamically the structure of statically defined Grid you should check this help topic.

    Regards,
    Andrey
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Massimiliano
    Massimiliano avatar
    184 posts
    Member since:
    Oct 2012

    Posted 16 Jul 2013 Link to this post

    Hallo Andrey, at the moment the whole grid is declarative and in .aspx page. Also I'm just using the AllowColumnsReorder="true" built in property. I don't think this scenario, wich is the default should require additional handling in code behind so I guess there must be some other issue to look at.
    Infact I don't want to define dynamically the structure of my declarative RadGrid neither I want on postback, I would just like the AllowColumnsReorder="true" functionality to work as expected.
    Any hints on where to look at?
  5. Andrey
    Admin
    Andrey avatar
    836 posts

    Posted 17 Jul 2013 Link to this post

    Hi,

    Yes, when you have defined the Grid declaratively there should be no problem working with the reordering of the columns. Could you compare your code with this demo and let me know what are the differences?

    Regards,
    Andrey
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  6. Massimiliano
    Massimiliano avatar
    184 posts
    Member since:
    Oct 2012

    Posted 17 Jul 2013 Link to this post

    OK Andrey thanks for your feedback.
    It seems I have found the root of the evil :)
    If I set EditMode="Batch" i have the error I provided to you when trying to reorder the columns (not in editing mode btw just in normal display modoe). If I set eny other EditMode reordering works as expected.
    This is a deeper issue since it seems I have problems with Batch editing mode infact.
    If I set EditMode="Batch" and <BatchEditingSettings EditType="Row" OpenEditingEvent="DblClick" /> when I select a row (even before attemping to double click it then) I got this JS error:
    Uncaught TypeError: Cannot read property '_data' of null
    It seems that just setting EditMode="Batch" triggers all those errors.

    Do you want me to open another topic on that subject?



  7. Andrey
    Admin
    Andrey avatar
    836 posts

    Posted 22 Jul 2013 Link to this post

    Hello,

    Could you try to download the latest internal build that will be available tomorrow(23th of July) and check whether the issues will still be replicates? Our developers have fixed some bugs related to batch editing in this release and they might affect you as well.

    Regards,
    Andrey
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  8. Massimiliano
    Massimiliano avatar
    184 posts
    Member since:
    Oct 2012

    Posted 22 Jul 2013 Link to this post

    Thank you Andrei much appreciated.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017