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

Radgrid export to pdf exception

12 Answers 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Partha
Top achievements
Rank 1
Partha asked on 20 Jul 2011, 10:12 AM
When I am trying to export to pdf from telerik radgrid,the following exception is getting thrown : 

Telerik.Apoc.ApocException: The id "ctl00_ctl00_BodyContentPlaceHolder_BodyContentPlaceHolder_SearchModifiedContent_ModifiedContentList_ModifiedContentsReportGrid_ctl01_ctl02_ctl00_lblClientName" already exists in this document
  at Telerik.Apoc.DataTypes.IDReferences.CreateID(String id)
  at Telerik.Apoc.Fo.FObjMixed.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.TableCell.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.TableRow.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.AbstractTableBody.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.Table.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.Flow.Layout(Area area, Region region)
  at Telerik.Apoc.Fo.Flow.Flow.Layout(Area area)
  at Telerik.Apoc.Fo.Pagination.PageSequence.Format(AreaTree areaTree)
  at Telerik.Apoc.StreamRenderer.Render(PageSequence pageSequence)
  at Telerik.Apoc.Fo.FOTreeBuilder.EndElement()
  at Telerik.Apoc.Fo.FOTreeBuilder.Parse(XmlReader reader)

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.SystemException: Telerik.Apoc.ApocException: The id "ctl00_ctl00_BodyContentPlaceHolder_BodyContentPlaceHolder_SearchModifiedContent_ModifiedContentList_ModifiedContentsReportGrid_ctl01_ctl02_ctl00_lblClientName" already exists in this document
  at Telerik.Apoc.DataTypes.IDReferences.CreateID(String id)
  at Telerik.Apoc.Fo.FObjMixed.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.TableCell.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.TableRow.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.AbstractTableBody.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.Table.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.Flow.Layout(Area area, Region region)
  at Telerik.Apoc.Fo.Flow.Flow.Layout(Area area)
  at Telerik.Apoc.Fo.Pagination.PageSequence.Format(AreaTree areaTree)
  at Telerik.Apoc.StreamRenderer.Render(PageSequence pageSequence)
  at Telerik.Apoc.Fo.FOTreeBuilder.EndElement()
  at Telerik.Apoc.Fo.FOTreeBuilder.Parse(XmlReader reader)

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:

[SystemException: Telerik.Apoc.ApocException: The id "ctl00_ctl00_BodyContentPlaceHolder_BodyContentPlaceHolder_SearchModifiedContent_ModifiedContentList_ModifiedContentsReportGrid_ctl01_ctl02_ctl00_lblClientName" already exists in this document
   at Telerik.Apoc.DataTypes.IDReferences.CreateID(String id)
   at Telerik.Apoc.Fo.FObjMixed.Layout(Area area)
   at Telerik.Apoc.Fo.Flow.Block.Layout(Area area)
   at Telerik.Apoc.Fo.Flow.TableCell.Layout(Area area)
   at Telerik.Apoc.Fo.Flow.TableRow.Layout(Area area)
   at Telerik.Apoc.Fo.Flow.AbstractTableBody.Layout(Area area)
   at Telerik.Apoc.Fo.Flow.Table.Layout(Area area)
   at Telerik.Apoc.Fo.Flow.Block.Layout(Area area)
   at Telerik.Apoc.Fo.Flow.Flow.Layout(Area area, Region region)
   at Telerik.Apoc.Fo.Flow.Flow.Layout(Area area)
   at Telerik.Apoc.Fo.Pagination.PageSequence.Format(AreaTree areaTree)
   at Telerik.Apoc.StreamRenderer.Render(PageSequence pageSequence)
   at Telerik.Apoc.Fo.FOTreeBuilder.EndElement()
   at Telerik.Apoc.Fo.FOTreeBuilder.Parse(XmlReader reader)]
   Telerik.Apoc.ApocDriver.FireApocError(String message) +82
   Telerik.Apoc.Fo.FOTreeBuilder.Parse(XmlReader reader) +699
   Telerik.Apoc.ApocDriver.Render(XmlReader inputReader, Stream outputStream) +206
   Telerik.Apoc.ApocDriver.Render(TextReader inputReader, Stream outputStream) +43
   Telerik.WebControls.Grid.Export.TableViewExporter.PdfExportRenderForm(HtmlTextWriter nullWriter, Control form) +832
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +109
   System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +8696541
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +31
   System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +53
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
   System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40
   Telerik.WebControls.Grid.Export.TableViewExporter.PdfExportRenderPage(HtmlTextWriter nullWriter, Control page) +107
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +109
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
   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) +100
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2671

Can anyone provide some inputs as to how to solve this?

12 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 20 Jul 2011, 10:25 AM
Hello Partha,

Check the following help documentation which explains about Exceptions incurred when exporting to pdf. Hope this helps.
PDF export.

Thanks,
Princy.
0
Partha
Top achievements
Rank 1
answered on 20 Jul 2011, 10:37 AM
Princy ,

I am presently using a commanditem template and also I have some nested controls inside that.So I think there is some issue with the commanditem template and the nested controls.  I am using paging for the grid.


Thanks,
Partha.
0
Partha
Top achievements
Rank 1
answered on 29 Aug 2011, 10:09 AM

Hi,
May be the cause for the exception is if you have commandItemTemplate, and nested controls in it. The controls from the command item which is embedded in the resulting document is multiplied for all pages.How to solve this problem?

Thanks,
Partha.
0
Princy
Top achievements
Rank 1
answered on 29 Aug 2011, 10:32 AM
Hello Partha,

I am not sure whether you want to export the controls inside CommandItemTemplate. If not try to set ExportOnlyDara as 'True' like below.

<ExportSettings ExportOnlyData="true">
 </ExportSettings>

Thanks,
Princy.
0
Partha
Top achievements
Rank 1
answered on 15 Sep 2011, 05:03 AM
Princy,

I need to have  the command template item in the exported file.So I cannot make ExportOnlyData="true".Please suggest a workaround.


Thanks,
Partha.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 15 Sep 2011, 06:11 AM
0
Partha
Top achievements
Rank 1
answered on 16 Sep 2011, 09:28 AM
Hi Jayesh,

I am already using   <MasterTableView  Width="100%" TableLayout="Fixed" in my code .But is seems it is not working.


Thanks,
Partha.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 16 Sep 2011, 10:04 AM
Hello,

if you used DetailTable than also give width to it.
let me know its working or not.

Thanks,
Jayesh Goyani
0
Partha
Top achievements
Rank 1
answered on 17 Sep 2011, 06:48 AM
Hello,

I am not using a DetailTable in my code.Here is the code i am using :

  <telerik:RadGrid ID="ModifiedContentsReportGrid" runat="server" AutoGenerateColumns="false"
                AllowPaging="true" EnableOutsideScripts="true" PagerStyle-Mode="NextPrevAndNumeric"
                ShowFooter="true" OnItemCreated="ModifiedContentsReportsGrid_OnItemCreated" Title="Modified Content Report"
                Height="100%" ExportSettings-ExportOnlyData="false" EnableViewState="true">
                <ItemStyle BackColor="transparent" />
                <AlternatingItemStyle BackColor="#F9F9F9" />
                <ExportSettings OpenInNewWindow="true" FileName="Modified Content Report" ExportOnlyData="false">
                    <Pdf PaperSize="A4" AllowPrinting="true" PageBottomMargin="10px" PageTopMargin="25px"
                        PageHeaderMargin="0px" PageLeftMargin="10px" PageRightMargin="10px" PageTitle="Modified Content Report"/>
                </ExportSettings>
                <HeaderStyle HorizontalAlign="Center" />
                <ClientSettings>
                    <Scrolling UseStaticHeaders="true" />
                </ClientSettings>
                <MasterTableView Width="100%" CommandItemDisplay="Top" CommandItemStyle-HorizontalAlign="Right"
                    TableLayout="Auto">
                    <CommandItemTemplate>
                        <asp:Literal runat="server"><b>Account Name :</b></asp:Literal>
                        <asp:Label ID="lblClientName" runat="server" /><br />
                        <asp:Literal runat="server"><b>Report generated on :</b></asp:Literal>
                        <asp:Label ID="lblGenerateDate" runat="server" /><br />
                        <asp:Literal runat="server"><b>Date Range :</b></asp:Literal>
                        <asp:Label ID="lblDateRange" runat="server" />
                    </CommandItemTemplate>
                    <Columns>
                        <telerik:GridBoundColumn DataField="Name" SortExpression="Name" HeaderText="Content File"
                            SortAscImageUrl="/Images/SortAsc.gif" SortDescImageUrl="/Images/SortDesc.gif"
                            ItemStyle-Width="30%">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Location" SortExpression="Location" HeaderText="Location"
                            SortAscImageUrl="/Images/SortAsc.gif" SortDescImageUrl="/Images/SortDesc.gif"
                            ItemStyle-Width="30%">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Project/Folder" SortExpression="Project/Folder"
                            HeaderText="Project/Folder" SortAscImageUrl="/Images/SortAsc.gif" SortDescImageUrl="/Images/SortDesc.gif"
                            ItemStyle-Width="10%">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Document" SortExpression="Document" HeaderText="Document"
                            SortAscImageUrl="/Images/SortAsc.gif" SortDescImageUrl="/Images/SortDesc.gif"
                            ItemStyle-Width="10%">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Section" SortExpression="Section" HeaderText="Section"
                            SortAscImageUrl="/Images/SortAsc.gif" SortDescImageUrl="/Images/SortDesc.gif"
                            ItemStyle-Width="10%">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="JobNumber" SortExpression="JobNumber" HeaderText="Job Number"
                            SortAscImageUrl="/Images/SortAsc.gif" SortDescImageUrl="/Images/SortDesc.gif"
                            ItemStyle-Width="10%">
                        </telerik:GridBoundColumn>
                    </Columns>
                    <NoRecordsTemplate>
                        <asp:Literal runat="server">
                    No records to display.</asp:Literal>
                    </NoRecordsTemplate>
                </MasterTableView>
                <PagerStyle Mode="NextPrevAndNumeric" />
            </telerik:RadGrid>


Please suggest a solution to this problem.I have noticed that it is happening only when we have pagination in the grid. For a single page in the grid it is working fine.Can that be a problem?

Thanks,
Partha.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 17 Sep 2011, 07:43 AM
Hello Partha,

I am not able to generate the issue (wih pagging/PageSize also).
please see attached file for more info.
if you still not solved the issue then please submit your project.

<telerik:RadGrid ID="ModifiedContentsReportGrid" runat="server" AutoGenerateColumns="false" OnNeedDataSource="ModifiedContentsReportGrid_NeedDataSource"
            AllowPaging="true" EnableOutsideScripts="true" PagerStyle-Mode="NextPrevAndNumeric"
            ShowFooter="true" Title="Modified Content Report" Height="100%" ExportSettings-ExportOnlyData="false"
            EnableViewState="true">
            <ItemStyle BackColor="transparent" />
            <AlternatingItemStyle BackColor="#F9F9F9" />
            <ExportSettings OpenInNewWindow="true" FileName="Modified Content Report" ExportOnlyData="false">
                <Pdf PaperSize="A4" AllowPrinting="true" PageBottomMargin="10px" PageTopMargin="25px"
                    PageHeaderMargin="0px" PageLeftMargin="10px" PageRightMargin="10px" PageTitle="Modified Content Report" />
            </ExportSettings>
            <HeaderStyle HorizontalAlign="Center" />
            <ClientSettings>
                <Scrolling UseStaticHeaders="true" />
            </ClientSettings>
            <MasterTableView Width="100%" CommandItemDisplay="Top" CommandItemStyle-HorizontalAlign="Right"
                TableLayout="Auto">
                <CommandItemSettings ShowExportToPdfButton="true" />
                <Columns>
                    <telerik:GridBoundColumn DataField="Name" SortExpression="Name" HeaderText="Content File"
                        ItemStyle-Width="30%">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Location" SortExpression="Location" HeaderText="Location"
                        ItemStyle-Width="30%">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ProjectFolder" SortExpression="ProjectFolder"
                        HeaderText="Project/Folder" ItemStyle-Width="10%">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Document" SortExpression="Document" HeaderText="Document"
                        ItemStyle-Width="10%">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Section" SortExpression="Section" HeaderText="Section"
                        ItemStyle-Width="10%">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="JobNumber" SortExpression="JobNumber" HeaderText="Job Number"
                        ItemStyle-Width="10%">
                    </telerik:GridBoundColumn>
                </Columns>
                <NoRecordsTemplate>
                    <asp:Literal ID="Literal4" runat="server">
                    No records to display.</asp:Literal>
                </NoRecordsTemplate>
            </MasterTableView>
            <PagerStyle Mode="NextPrevAndNumeric" />
        </telerik:RadGrid>
protected void ModifiedContentsReportGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        dynamic data = new[] {
                new { Name = "1", Location ="Location1",ProjectFolder = "Project/Folder1",Document="Document1",Section="Section1",JobNumber=123 },
                new { Name = "2", Location ="Location1",ProjectFolder = "Project/Folder1",Document="Document1",Section="Section1",JobNumber=123 },
                new { Name = "3", Location ="Location1",ProjectFolder = "Project/Folder1",Document="Document1",Section="Section1",JobNumber=123 }
 
                 
            };
 
        ModifiedContentsReportGrid.DataSource = data;
    }



Thanks,
Jayesh Goyani
0
Daniel
Telerik team
answered on 17 Sep 2011, 11:13 AM
Hi guys,

I recommend that you try to hide the pager item (on ItemCreated) before exporting.
PDF export help topic (Hiding Items section)

Regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start 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
0
Partha
Top achievements
Rank 1
answered on 27 Sep 2011, 07:06 AM
Resolved the issue.We have to use use  asp literal control instead of asp label control. It is working properly now.Issue was happening only when pagination was involved.

Thanks,
Partha.
Tags
Grid
Asked by
Partha
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Partha
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Daniel
Telerik team
Share this question
or