This is a migrated thread and some comments may be shown as answers.

RadGrid NestedViewTemplate Generate - System.InvalidOperationException: Collection was modified; enumeration operation may not execute

1 Answer 147 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Davy
Top achievements
Rank 1
Davy asked on 23 Dec 2012, 02:00 PM
Hello,

I'm encountering an exception using RadGrid's NestedViewTemplate feature.
If I set HierarchyDefaultExpanded="true" RadGrid, NestedViewTemplate is rendering correctly but all rows are expanded which is not very interesting. So i leave HierarchyDefaultExpanded to false so rows are initially collapsed when i expand a row following exception is raised

[System.InvalidOperationException: Collection was modified; enumeration operation may not execute.]
System.Web.UI.ControlCollectionEnumerator.MoveNext() +8672514
   Telerik.Web.UI.RadFormDecorator.FindAndDecorateControls(Control parent) +639
   Telerik.Web.UI.RadFormDecorator.FindAndDecorateControls(Control parent) +630
   Telerik.Web.UI.RadFormDecorator.FindAndDecorateControls(Control parent) +630
   Telerik.Web.UI.RadFormDecorator.FindAndDecorateControls(Control parent) +630
   Telerik.Web.UI.RadFormDecorator.FindAndDecorateControls(Control parent) +630
   Telerik.Web.UI.RadFormDecorator.FindAndDecorateControls(Control parent) +630
   Telerik.Web.UI.RadFormDecorator.FindAndDecorateControls(Control parent) +630
   Telerik.Web.UI.RadFormDecorator.FindAndDecorateControls(Control parent) +630
   Telerik.Web.UI.RadFormDecorator.FindAndDecorateControls(Control parent) +630
   Telerik.Web.UI.RadFormDecorator.FindAndDecorateControls(Control parent) +630
   Telerik.Web.UI.RadFormDecorator.FindAndDecorateControls(Control parent) +630
   Telerik.Web.UI.RadFormDecorator.FindAndDecorateControls(Control parent) +630
   Telerik.Web.UI.RadFormDecorator.FindAndDecorateControls(Control parent) +630
   Telerik.Web.UI.RadFormDecorator.DecorateAspNetControls() +68
   Telerik.Web.UI.RadFormDecorator.ControlPreRender() +834
   Telerik.Web.UI.RadWebControl.OnPreRender(EventArgs e) +47
   System.Web.UI.Control.PreRenderRecursiveInternal() +80
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
 
I have tested a lot of scenarios with no success. RadGrids are both initialized programmatically (ItemCommand, ItemCreated, PreRender, NeedDataSource for NHibernate list).

After testing, exception raise when system tries to render manual columns (GridDateTimeColumn, GridBoundColumn) as  AutoGenerateColumns="False". If i remove manual columns, expand/collapse is working.

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 25 Dec 2012, 01:08 PM
Hello Davy,

For a practical implementation of hierarchical grid structure, please check out the following demos:
  - Standard Hierarchy
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/declarativerelations/defaultcs.aspx
  - Programmatic Hierarchy
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/autogeneratedhierarchy/defaultcs.aspx
  - Hierarchy with Templates
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/nestedviewtemplate/defaultcs.aspx
  - Template relations
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/nestedviewtemplatedeclarativerelations/defaultcs.aspx
  - Master / Detail grids
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/selectedvalue/defaultcs.aspx

and choose the approach most suitable to your specific requirements.

If you are creating your grid programmatically, please note that RadGrid does not support mixing declarative grid columns with grid columns added dynamically at runtime as stated in this topic:
http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html#Section4

I hope this will prove helpful.

Kind regards,
Eyup
the Telerik team
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 their blog feed now.
Tags
Grid
Asked by
Davy
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or