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

[Solved] RadGrid Export Error: Script controls may not be registered after PreRender

2 Answers 255 Views
Grid
This is a migrated thread and some comments may be shown as answers.
RR
Top achievements
Rank 1
RR asked on 14 Apr 2008, 07:24 PM

I am working inside of a DotNetNuke (DNN) module which has partial page update enabled. I have a RadGrid "Prometheus" inside of this module with export capability. The grid is bound dynamically to a dataset in the RadGrid1_NeedDataSource event.

I implemented RadGrid "Prometheus" Export with AJAX using the sample given.
http://www.telerik.com/community/code-library/submission/b311D-ttcbe.aspx

The particular example I used from this posting was: 078227_RadGridExportFromWithinUpdatePanel_Web_UI.zip

This is because when partial page update is enabled for a DNN module, it places the whole module within an update panel.

I used the following settings:
RadGrid1.ExportSettings.IgnorePaging = true;
RadGrid1.ExportSettings.ExportOnlyData = true;

And it works fine.

Then I used another sample from the Telerik forums to change the header text of the RadGrid columns:
protected void RadGrid1_PreRender(object sender, EventArgs e)
        {
            if (Session["headerTexts"] != null)
            {
                Hashtable headerTexts = (Hashtable)Session["headerTexts"];
                foreach (string key in headerTexts.Keys)
                {
               GridColumn column = RadGrid1.MasterTableView.GetColumn(key);
                    column.HeaderText = headerTexts[key].ToString();
                }
                RadGrid1.Rebind();
            }                                                
        }


And this works fine too!

However, now when I export after I added the header text change in the pre-render event I get the following error:
Script controls may not be registered after PreRender.

Also notice that it says "after" pre-render. There are some posts on the web related to "before" pre-render.

If I take out the header text change in the pre-render event, it works fine.

I would appreciate if someone could tell me the solution to the above problem.

Thanks,
Tal








2 Answers, 1 is accepted

Sort by
0
RR
Top achievements
Rank 1
answered on 14 Apr 2008, 09:33 PM

I was able to resolve this issue by moving the change of header text into the column created event instead of the pre-render event. 

protected void RadGrid1_ColumnCreated(object sender, Telerik.Web.UI.GridColumnCreatedEventArgs e)
        { 

GridColumn boundColumn = e.Column as GridColumn;        
if (Session["headerTexts"] != null)
{
                Hashtable headerTexts = (Hashtable)Session["headerTexts"];
                if(headerTexts.ContainsKey(boundColumn.HeaderText)); boundColumn.HeaderText =
headerTexts[boundColumn.HeaderText].ToString();
}
}


I am still curious though, how to resolve the issue if a srcipt when it is registered after pre-rendering the grid. 

Thanks,
Tal

0
Yavor
Telerik team
answered on 18 Apr 2008, 07:32 AM
Hi RR,

There are a number of causes which may be causing this behavior. Does the issue occur outside DNN, or is it related only to the module? Do you have any paging enabled? Additionally, you may open a formal support ticket, and send us a small working project, which demonstrates the issue, so that we can debug it further.

Regards,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
RR
Top achievements
Rank 1
Answers by
RR
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or