RadFilter error when trying to export RadGrid to excel file

6 posts, 0 answers
  1. Juan Camilo De Argaez
    Juan Camilo De Argaez avatar
    4 posts
    Member since:
    Mar 2010

    Posted 14 Apr 2010 Link to this post

    Hello,

    I have a RadGrid with the export to excel command enabled, and a RadFilter to filter the grid data.

    When I try to export the grid to excel after applying filters, an exception occurs.
    But the grid exports fine to excel if no filters are applied.

    Please explain how to fix or workaround the problem.

    Exception Info:

    Script controls may not be registered after PreRender.

    Description:An unhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about the error andwhere it originated in the code.

    Exception Details:System.InvalidOperationException: Script controls may not be registeredafter PreRender.

    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:

    [InvalidOperationException: Script controls may not be registered after PreRender.]   System.Web.UI.ScriptControlManager.RegisterScriptControl(TScriptControl scriptControl) +206   System.Web.UI.ScriptManager.RegisterScriptControl(TScriptControl scriptControl) +67   Telerik.Web.UI.RadInputControl.RegisterScriptControl() +42   Telerik.Web.UI.RadWebControl.ControlPreRender() +15   Telerik.Web.UI.RadInputControl.ControlPreRender() +12   Telerik.Web.UI.RadNumericTextBox.OnPreRender(EventArgs e) +152   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.Control.PreRenderRecursiveInternal() +171   System.Web.UI.Control.PreRenderRecursiveInternal() +171   System.Web.UI.Control.AddedControl(Control control, Int32 index) +8682853   System.Web.UI.ControlCollection.Add(Control child) +80   Telerik.Web.UI.RadFilter.CreateFilterItems() +504   Telerik.Web.UI.RadFilter.CreateControlHierarchy() +13   Telerik.Web.UI.RadFilter.CreateChildControls() +78   System.Web.UI.Control.EnsureChildControls() +87   Telerik.Web.UI.RadFilter.RecreateControl() +44   Telerik.Web.UI.RadFilter.ContainerFieldDescriptorsReady(Object sender, RadFilterFildDesciptorsEventArgs e) +27   Telerik.Web.UI.RadGrid.OnFieldDescriptorsReady(RadFilterFildDesciptorsEventArgs e) +65   Telerik.Web.UI.RadGrid.UpdateFilterControl() +130   Telerik.Web.UI.GridTableView.SavePagingData(Boolean useDataSource, GridPagingManager paging) +228   Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +1001   Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +500   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142   Telerik.Web.UI.GridTableView.PerformSelect() +4   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73   Telerik.Web.UI.GridTableView.DataBind() +224   Telerik.Web.UI.RadGrid.DataBind() +80   Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason) +2132   Telerik.Web.UI.RadGrid.RebindForExport() +95   Telerik.Web.UI.Grid.Export.TableViewExporter.ExcelExportRenderForm(HtmlTextWriter nullWriter, Control form) +853   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19   System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +8677897   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32   System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +51   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99   System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40   Telerik.Web.UI.Grid.Export.TableViewExporter.ExcelExportRenderPage(HtmlTextWriter nullWriter, Control page) +93   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19   System.Web.UI.Page.Render(HtmlTextWriter writer) +29   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25   Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +640   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19   System.Web.UI.Page.Render(HtmlTextWriter writer) +29   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266

    Aspx snippets:

    <script type="text/javascript"
        //<![CDATA[ 
            function RequestStart(sender, args) { 
                if (args.get_eventTarget().indexOf("ExportToExcelButton") != -1) { 
                    args.set_enableAjax(false); 
                } 
            } 
        //]]> 
        </script> 

    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
         
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" onajaxrequest="RadAjaxManager1_AjaxRequest" ClientEvents-OnRequestStart="RequestStart"
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="gridClientes" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
                <telerik:AjaxSetting AjaxControlID="gridClientes"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="gridClientes" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
            <ClientEvents OnRequestStart="RequestStart" /> 
        </telerik:RadAjaxManager> 

    <div><telerik:RadFilter ID="RadFilter1" runat="server" FilterContainerID="gridClientes" ShowApplyButton="True" /></div
                        <telerik:RadGrid ID="gridClientes" runat="server" GridLines="None" 
                            AutoGenerateColumns="False" AllowPaging="True" AllowSorting="True" 
                            OnSortCommand="gridClientes_SortCommand" OnPageIndexChanged="gridClientes_PageIndexChanged" OnPageSizeChanged="gridClientes_PageSizeChanged" 
                            OnNeedDataSource="gridClientes_NeedDataSource" OnItemCommand="gridClientes_ItemCommand" OnUpdateCommand="gridClientes_UpdateCommand" OnItemDataBound="gridClientes_ItemDataBound" 
                            PageSize="50"
                             <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" EditMode="InPlace"
                                <CommandItemSettings ShowExportToExcelButton="true" ExportToExcelText="Exportar a Excel" ShowRefreshButton="False" ShowAddNewRecordButton="False" /> 
                                 
                                <Columns> 
                                   <Columns> 
                                    <telerik:GridBoundColumn DataField="Field1" SortExpression="Field1" UniqueName="Field1"></telerik:GridBoundColumn> 
                                    <telerik:GridBoundColumn DataField="Field2" SortExpression="Field2" UniqueName="Field2"></telerik:GridBoundColumn> 
                                    <telerik:GridBoundColumn DataField="Field3" SortExpression="Field3" UniqueName="Field3"></telerik:GridBoundColumn> 
                                </Columns> 
                             </MasterTableView> 
                             <ClientSettings EnableRowHoverStyle="True" ReorderColumnsOnClient="True" AllowColumnsReorder="True"
                                <ClientEvents OnRowSelected="gridClientes_OnRowSelected" /> 
                                <Selecting AllowRowSelect="True" /> 
                                <Scrolling AllowScroll="True" UseStaticHeaders="True"></Scrolling> 
                                <Resizing AllowColumnResize="true" /> 
                             </ClientSettings> 
                             <ExportSettings FileName="clientes"  OpenInNewWindow="True" IgnorePaging="True"  Excel-Format="ExcelML" ExportOnlyData="True"></ExportSettings> 
                             <PagerStyle AlwaysVisible="true" Position="Bottom" /> 
                        </telerik:RadGrid> 


    Thanks in advance.
  2. Juan Camilo De Argaez
    Juan Camilo De Argaez avatar
    4 posts
    Member since:
    Mar 2010

    Posted 15 Apr 2010 Link to this post

    The problem happens with the RadFilter RadNumericTextBox.
    If I apply a filter that doesn't contain any numerictextbox, the grid exports fine to excel.

    I need to fix this problem urgently. Please help.
    Can this be a bug or an issue on RadNumericTextBox PreRender?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Juan Camilo De Argaez
    Juan Camilo De Argaez avatar
    4 posts
    Member since:
    Mar 2010

    Posted 15 Apr 2010 Link to this post

    I finally figured out whats going on.

    There are problems between RadNumericInput and ExcelML format.
    If export format is set to ExcelML in export settings the exception ocurrs.
  5. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 16 Apr 2010 Link to this post

    Hello Juan,

    I am afraid that you are right. However we managed to fix the issue and the fix will be available within next internal build which will be available in few days and you can download from your account.

    Regards,
    Nikolay
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. Mozilla
    Mozilla avatar
    1 posts
    Member since:
    Nov 2010

    Posted 30 Nov 2010 Link to this post

    Hi,
    I have HtmlEncoded the data before saving it in DB, now when I exporting the data to file, the encoded data is showen.
    How can I Html decode the data before exporting it to file?

    Do I need to decode first? Or there is some other way to export the file as the browser display it?
  7. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 03 Dec 2010 Link to this post

    Hello Mozilla,

    One possible solution is to provide the data as raw, not encoded string. RadGrid bound column has property HtmlEncode which will ensure that the data will be shown properly.

    Other options if the data is already encoded is to modify the content of the cell of RadGrid before export.

    Best wishes,
    Nikolay
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017