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

Dymanic control recreate error with radgrid inside

2 Answers 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Karen
Top achievements
Rank 1
Karen asked on 21 Jun 2009, 10:34 AM
Hi

I am using radtabstrib and adding tabs and page views dynamically, page views itself has user controls inside, so I am recreating all this on each postback, however everything works perfect until I put radgrid inside the user control (it works ok with regular GridView) the error is the following.
The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.

The exception throws as soon as I try to add user control with rad grid inside, into the page view
private void RecreateTabsPageViews() 
    { 
        if (Session["TabPageViewsContents"] == nullreturn
        List<Control> PageViewsList = (List<Control>)Session["TabPageViewsContents"]; 
        int index = 0; 
        foreach (Control c in PageViewsList) 
        { 
            CenterTabStribMultiPage.PageViews[index].Controls.Add(c); 
            index++; 
        } 
    } 

Please advice.
Thanks

2 Answers, 1 is accepted

Sort by
0
Karen
Top achievements
Rank 1
answered on 21 Jun 2009, 03:11 PM
Update: Seems this is a problem with all rad controls, it is impossible to recreate user controls that have any of the rad controls inside
0
Sebastian
Telerik team
answered on 24 Jun 2009, 03:37 PM
Hello Karen,

I tried to reproduce the issue you depicted locally but my attempts were not successful. To progress in our investigation, is it possible for you to post the problematic page/user control along with their code-behind in this forum post using the 'Format Code Block' option at the top right corner of the forum editor? Thus I will examine your implementation in detail and will do my best to provide an accurate explanation/fix.

You may also perform a quick test and see whether the same error appears when you remove the RadGrid instance from the user control, add a standard MS GridView in it and bind it to data.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Karen
Top achievements
Rank 1
Answers by
Karen
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or