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

[Solved] export to excel problem

7 Answers 437 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Achim
Top achievements
Rank 1
Achim asked on 28 Feb 2008, 10:43 AM
Hi,

i have a problem wih RadGrid when exporting to excel.. The Problem occurs if three things are present:

1) inside the CommandItemTemplate there is a usercontrol
<CommandItemTemplate> 
       <uc2:test ID="Test1" runat="server" /> 
</CommandItemTemplate> 

2) inside the UserControl test.ascx there is another control from Prometheus, eg a RadTextbox

3) now when i have a ajaxified grid inside MS-UpdatePanel with UserControl in CommandItemTemplate and use
RadGrid1.ExportSettings.IgnorePaging = false
everything works ok.

But when i try to set to use
ExportSettings.IgnorePaging = true;

i will get an error

Script controls may not be registered after PreRender.

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.InvalidOperationException: Script controls may not be registered after PreRender.

Source Error:

            Line 8:    <asp:LinkButton ID="btnExport" runat="server" CommandName="exportexcel" OnClick="btnExport_Click">LinkButton</asp:LinkButton>
Line 9: <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" GridLines="None"
Line 10: AllowPaging="True" AllowSorting="True" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True"
Line 11: AllowMultiRowEdit="True" AllowMultiRowSelection="True" OnItemDataBound="RadGrid1_ItemDataBound"

Stack Trace:

[InvalidOperationException: Script controls may not be registered after PreRender.]
System.Web.UI.ScriptControlManager.RegisterScriptControl(TScriptControl scriptControl) +269
System.Web.UI.ScriptManager.RegisterScriptControl(TScriptControl scriptControl) +99
Telerik.Web.UI.RadWebControl.RegisterScriptControl() +26
Telerik.Web.UI.RadWebControl.OnPreRender(EventArgs e) +19
Telerik.Web.UI.RadInputControl.OnPreRender(EventArgs e) +10
System.Web.UI.Control.PreRenderRecursiveInternal() +86
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.AddedControl(Control control, Int32 index) +2115833
System.Web.UI.ControlCollection.Add(Control child) +146
System.Web.UI.Control.AddParsedSubObject(Object obj) +38
System.Web.UI.WebControls.TableCell.AddParsedSubObject(Object obj) +195
System.Web.UI.Control.System.Web.UI.IParserAccessor.AddParsedSubObject(Object obj) +7
ASP.gui3_parts_grids_dokugrid_org_ascx.__BuildControl__control6(Control __ctrl) in d:\01..Eigene Dateien\01..Projekte Develop\wwwroot\Quisa\gui3_parts\grids\dokugrid_org.ascx:9
System.Web.UI.CompiledTemplateBuilder.InstantiateIn(Control container) +12
Telerik.Web.UI.GridCommandItem.InitializeCommandItem() +97
Telerik.Web.UI.GridCommandItem.SetupItem(Boolean dataBind, Object dataItem, GridColumn[] columns, ControlCollection rows) +72
Telerik.Web.UI.GridTableView.CreateBottomCommandItem(Boolean useDataSource, GridColumn[] copiedColumnSet, GridTFoot tfoot) +109
Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +770
Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +481
System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +59
System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +111
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +29
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
Telerik.Web.UI.GridTableView.PerformSelect() +4
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
Telerik.Web.UI.GridTableView.DataBind() +298
Telerik.Web.UI.RadGrid.DataBind() +93
Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason) +181
Telerik.Web.UI.RadGrid.RebindForExport() +96
Telerik.Web.UI.Grid.Export.TableViewExporter.PrepareForExport() +210
Telerik.Web.UI.Grid.Export.TableViewExporter.ExcelExportRenderForm(HtmlTextWriter nullWriter, Control form) +84
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +98
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +59
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +68
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +37
Telerik.Web.UI.Grid.Export.TableViewExporter.ExcelExportRenderPage(HtmlTextWriter nullWriter, Control page) +102
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +98
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.Page.Render(HtmlTextWriter writer) +26
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2558

can you please have a look whats wrong here?

thanks!
achim

7 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 05 Mar 2008, 12:43 PM
Hello Achim,

We must confirm that this is a bug in the control and can be reproduced when any control built on top of MS AJAX is placed within any RadGrid template (commandItem, Pager etc.). I've logged it in our system and forwarded it to our developers for fixing.

Your Telerik points have been updated for pointing this out. Please excuse us for the temporary inconvenience.

Regards,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Emeleen
Top achievements
Rank 1
answered on 10 Mar 2008, 06:06 PM
hi

is there a solution or workaround for this problem? I am getting the same one.
Thanks!

Emeleen
0
Steve
Telerik team
answered on 11 Mar 2008, 09:00 AM
Hi Emeleen,

This has been confirmed a few days ago and it is not included in the current TODO tasks (which are predefined 2 weeks in advance). It is logged in our system and we will make sure it is fixed for the official Prometheus release.

Sincerely yours,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
membersnow
Top achievements
Rank 1
answered on 27 Mar 2008, 09:37 PM
This problem exists in the q3 Prometheus 1425 build, even without any custom controls or anything unusual.  It seems to be dependent (as I've seen in other posts) on the IgnorePaging property - false works fine, true causes this crash.  Note the following grid:

                            <telerik:RadGrid ID="EventsGrid" runat="server" Width="100%" AllowSorting="true" 
                                AutoGenerateColumns="false" Skin="Web20" AllowFilteringByColumn="true" AllowPaging="true" 
                                OnItemCommand="EventsGrid_ItemCommand" DataSourceID="EventTicketsSqlDS" OnItemCreated="EventsGrid_ItemCreated" 
                                GridLines="Vertical" OnPreRender="EventsGrid_PreRender"
                                <AlternatingItemStyle BackColor="Azure" /> 
                                <PagerStyle Mode="NextPrevAndNumeric" /> 
                                <ClientSettings AllowColumnsReorder="True" AllowDragToGroup="False" ReorderColumnsOnClient="True"
                                    <Resizing AllowColumnResize="false" /> 
                                </ClientSettings> 
                                <GroupHeaderItemStyle Font-Bold="true" Font-Size="Medium" /> 
                                <ExportSettings OpenInNewWindow="true" IgnorePaging="false" ExportOnlyData="true"
                                </ExportSettings> 
                                <MasterTableView DataKeyNames="event_registration_id" TableLayout="Fixed" ShowFooter="false"
                                    <GroupByExpressions> 
                                        <telerik:GridGroupByExpression> 
                                            <SelectFields> 
                                                <telerik:GridGroupByField HeaderText="Registrants" FieldName="RegistrantCount" /> 
                                                <telerik:GridGroupByField HeaderText="Tickets" FieldName="TicketQuantity" Aggregate="Sum" /> 
                                                <telerik:GridGroupByField HeaderText="Value of Tickets" FieldName="SumPrice" Aggregate="Sum" 
                                                    FormatString="{0:C}" /> 
                                                <telerik:GridGroupByField HeaderText="Amount Paid" FieldName="amount" Aggregate="Sum" 
                                                    FormatString="{0:C}" /> 
                                                <telerik:GridGroupByField HeaderText="Amount Owed" FieldName="owed" Aggregate="Sum" 
                                                    FormatString="{0:C}" FieldAlias="amount_owed" /> 
                                            </SelectFields> 
                                            <GroupByFields> 
                                                <telerik:GridGroupByField FieldName="All" /> 
                                            </GroupByFields> 
                                        </telerik:GridGroupByExpression> 
                                        <telerik:GridGroupByExpression> 
                                            <SelectFields> 
                                                <telerik:GridGroupByField HeaderText="Tickets" FieldName="TicketQuantity" Aggregate="Sum" /> 
                                                <telerik:GridGroupByField HeaderText="Value of Tickets" FieldName="SumPrice" Aggregate="Sum" 
                                                    FormatString="{0:C}" /> 
                                                <telerik:GridGroupByField HeaderText="Amount Paid" FieldName="amount" Aggregate="Sum" 
                                                    FormatString="{0:C}" /> 
                                                <telerik:GridGroupByField HeaderText="Amount Owed" FieldName="owed" Aggregate="Sum" 
                                                    FormatString="{0:C}" /> 
                                            </SelectFields> 
                                            <GroupByFields> 
                                                <telerik:GridGroupByField FieldName="event_registration_id" /> 
                                            </GroupByFields> 
                                        </telerik:GridGroupByExpression> 
                                    </GroupByExpressions> 
                                    <Columns> 
                                        <telerik:GridBoundColumn HeaderText="First" DataField="er_first_name" UniqueName="FirstName"
                                            <ItemStyle Width="40" /> 
                                            <HeaderStyle HorizontalAlign="Center" /> 
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn HeaderText="Last" DataField="er_last_name" UniqueName="LastName"
                                            <ItemStyle Width="40" /> 
                                            <HeaderStyle HorizontalAlign="Center" /> 
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn HeaderText="Business" DataField="business_name" UniqueName="BusinessName"
                                            <ItemStyle Width="40" /> 
                                            <HeaderStyle HorizontalAlign="Center" /> 
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn HeaderText="Ticket Type" DataField="price_name" UniqueName="TicketType"
                                            <ItemStyle /> 
                                            <HeaderStyle Wrap="true" Width="80" HorizontalAlign="Center" /> 
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn HeaderText="# of Tickets" DataField="TicketQuantity" UniqueName="TicketQuantity"
                                            <ItemStyle HorizontalAlign="Right" /> 
                                            <HeaderStyle Wrap="true" Width="55" HorizontalAlign="Center" /> 
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn HeaderText="Amount Paid" DataFormatString="{0:C}" DataField="amount" 
                                            UniqueName="AmountPaid"
                                            <ItemStyle HorizontalAlign="Right" /> 
                                            <HeaderStyle Wrap="true" Width="65" HorizontalAlign="Center" /> 
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn HeaderText="Amount Owed" DataFormatString="{0:C}" DataField="owed" 
                                            UniqueName="AmountOwed"
                                            <ItemStyle HorizontalAlign="Right" /> 
                                            <HeaderStyle Wrap="true" Width="65" HorizontalAlign="Center" /> 
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn HeaderText="Phone" DataField="er_phone" UniqueName="Phone"
                                            <ItemStyle Width="70" /> 
                                            <HeaderStyle HorizontalAlign="Center" /> 
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn HeaderText="Email" DataField="email_address" UniqueName="Email"
                                            <ItemStyle Width="160" /> 
                                            <HeaderStyle HorizontalAlign="Center" Width="160" /> 
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridDateTimeColumn HeaderText="Date Registered" DataField="registration_date" 
                                            DataFormatString="{0:MM/dd/yyyy}" PickerType="DatePicker" UniqueName="RegistrationDate"
                                            <HeaderStyle Wrap="true" HorizontalAlign="Center" Width="115" /> 
                                        </telerik:GridDateTimeColumn> 
                                        <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="EditEventRegistration" 
                                            ImageUrl="~/images/icons/edit.png" Text="Edit Registration Info" HeaderText="Edit" 
                                            UniqueName="EditEventRegistration"
                                            <ItemStyle Width="30" /> 
                                            <HeaderStyle HorizontalAlign="Center" Width="30" /> 
                                        </telerik:GridButtonColumn> 
                                    </Columns> 
                                    <%--                                    <FooterStyle BackColor="#cc6633" />--%> 
                                </MasterTableView> 
                            </telerik:RadGrid> 
                            <asp:SqlDataSource ID="EventTicketsSqlDS" runat="server" ConnectionString="<%$ ConnectionStrings:SqlConnection %>" 
                                SelectCommand="usp_get_event_ticket_info" SelectCommandType="StoredProcedure"
                                <SelectParameters> 
                                    <asp:QueryStringParameter Name="event_id" QueryStringField="event_id" Type="Int32" /> 
                                </SelectParameters> 
                            </asp:SqlDataSource> 
 

This causes the problem as described, if I change to IgnorePaging="true"
0
Steve
Telerik team
answered on 28 Mar 2008, 10:52 AM
Hi membersnow,

We will investigate the problem and resolve it for the official Q1 release of Prometheus for sure. Once again please excuse us for the inconvenience.

Best wishes,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Prasad
Top achievements
Rank 1
answered on 14 May 2009, 11:22 AM
Hi Steve,

Was this Issue Resolved. Let us know which release of teleriks we need to download

I am currently using 

Telerik.Charting.dll ---  File Version 2.0.2.0
Telerik.Web.Design.dll ---  File Version 2007.3.1314.20
Telerik.Web.UI.dll ---  File Version 2008.2.826.35


Please Advice

Thanks
Prasad
0
Sebastian
Telerik team
answered on 14 May 2009, 11:35 AM
Hello Prasad,

The issue should be addressed in your version of the ASP.NET AJAX suite as well as in the latest release 2009.1.402. Upgrade instructions can be found here.

Best 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
Achim
Top achievements
Rank 1
Answers by
Steve
Telerik team
Emeleen
Top achievements
Rank 1
membersnow
Top achievements
Rank 1
Prasad
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or