This is a migrated thread and some comments may be shown as answers.
Export To PDF, Unable to cast object of type 'Telerik.Web.Apoc.Layout.BlockArea' to type 'Telerik.Web.Apoc.Layout.AreaContainer'.
8 Answers 217 Views
This is a migrated thread and some comments may be shown as answers.
Eric Krauska
Top achievements
Rank 1
Eric Krauska asked on 14 Sep 2011, 06:16 PM
I've seen this error reported multiple times, but none of the solutions seem to work for me.  Most of the answers for this error seem to be related to a div.  In the included source code you can see there is no div, absolute positioning, etc.  Please assist since this error is quite frustrating!  Version of RadControls:  v.2011.2.712.40

<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>   
    <telerik:RadGrid ID="_timeEntriesGrid" runat="server" AutoGenerateEditColumn="false" DataSourceID="_timeEntryDataSource" AllowAutomaticInserts="false" AllowAutomaticUpdates="false"
        GridLines="None" Skin="Forest" AutoGenerateColumns="False" GroupingEnabled="true" ShowGroupPanel="true" GroupLoadMode="Client" AllowPaging="true" PageSize="50"   >
        <ExportSettings IgnorePaging="false" OpenInNewWindow="true">
            <Pdf PageTitle="Time Entries" AllowPrinting="true" PaperSize="Letter" />
        </ExportSettings>
 
        <MasterTableView Caption="Time Entries Logged" AllowFilteringByColumn="true" CommandItemDisplay="Top" >
            <CommandItemSettings ShowAddNewRecordButton="false" ShowRefreshButton="true" ShowExportToPdfButton="true" />
            <RowIndicatorColumn><HeaderStyle Width="20px" /></RowIndicatorColumn>
            <ExpandCollapseColumn><HeaderStyle Width="20px" /></ExpandCollapseColumn>
            <Columns>
                <telerik:GridBoundColumn Groupable="true" DataField="ContractorDescription" HeaderText="Contractor" SortExpression="ContractorDescription" UniqueName="ContractorDescription" DataType="System.String"></telerik:GridBoundColumn>                       
                <telerik:GridBoundColumn Groupable="true" DataField="Name" HeaderText="Name" SortExpression="Name" UniqueName="Name" DataType="System.String"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Description" HeaderText="Log Type" SortExpression="Description" UniqueName="Description" DataType="System.String"></telerik:GridBoundColumn>
                <telerik:GridDateTimeColumn DataFormatString="{0:g}" DataField="TimeLogged" HeaderText="Time" SortExpression="TimeLogged" UniqueName="TimeLogged" DataType="System.DateTime"></telerik:GridDateTimeColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings AllowGroupExpandCollapse="True" ReorderColumnsOnClient="True" AllowDragToGroup="True" AllowColumnsReorder="True"></ClientSettings>
        <GroupingSettings ShowUnGroupButton="true" />
 
        <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default" EnableImageSprites="True"></HeaderContextMenu>
    </telerik:RadGrid>
    <telerik:OpenAccessDataSource ID="_timeEntryDataSource" runat="server"
        ObjectContextProvider="Keeley.Barcode.DAL.KeeleyBarcodeDataContext, Keeley.Barcode.DAL"
        TypeName="Keeley.Barcode.DAL.VwProjectTimeLog"
        OrderBy="TimeLogged DESC"
        Where="ProjectID == '08485ad8-6f37-41cf-8fc3-50ba91f87e05'" >
    </telerik:OpenAccessDataSource>
     
    </form>
</body>

And the error is:

System.InvalidCastException: Unable to cast object of type 'Telerik.Web.Apoc.Layout.BlockArea' to type 'Telerik.Web.Apoc.Layout.AreaContainer'.
  at Telerik.Web.Apoc.Fo.Flow.BlockContainer.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.TableCell.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.TableRow.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.AbstractTableBody.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Table.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area, Region region)
  at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Pagination.PageSequence.Format(AreaTree areaTree)
  at Telerik.Web.Apoc.StreamRenderer.Render(PageSequence pageSequence)
  at Telerik.Web.Apoc.Fo.FOTreeBuilder.EndElement()
  at Telerik.Web.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: System.InvalidCastException: Unable to cast object of type 'Telerik.Web.Apoc.Layout.BlockArea' to type 'Telerik.Web.Apoc.Layout.AreaContainer'.
  at Telerik.Web.Apoc.Fo.Flow.BlockContainer.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.TableCell.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.TableRow.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.AbstractTableBody.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Table.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area, Region region)
  at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Pagination.PageSequence.Format(AreaTree areaTree)
  at Telerik.Web.Apoc.StreamRenderer.Render(PageSequence pageSequence)
  at Telerik.Web.Apoc.Fo.FOTreeBuilder.EndElement()
  at Telerik.Web.Apoc.Fo.FOTreeBuilder.Parse(XmlReader reader)






8 Answers, 1 is accepted

Sort by
0
Eric Krauska
Top achievements
Rank 1
answered on 14 Sep 2011, 06:40 PM
FYI, I got this figured out.  The GridDateTimeColumn is what was causing the error.  I changed it to GridBoundColumn and it is working now. 
0
Jayesh Goyani
Top achievements
Rank 2
answered on 14 Sep 2011, 06:58 PM
Hello,

try with below property,

  <MasterTableView  Width="100%" TableLayout="Auto"
or
  <MasterTableView  Width="100%" TableLayout="Fixed"


let me know if any concern.

Thanks,
Jayesh Goyani
0
Russell
Top achievements
Rank 1
answered on 10 Feb 2012, 08:08 PM
I'm seeing the same error - when using a GridDateTimeColumn.  Changing it to a GridBoundColumn resolves the problem, however I then lose the benefit of specifing a GridDateTimeColumn. 
Does Telerik have an ETA for when they will be fixing this bug?

Note: I also tried the <MasterTableView> changes that were recommended by Jayesh, but there was no change in behavior.
0
Daniel
Telerik team
answered on 15 Feb 2012, 10:51 AM
Hi guys,

Please test the following workaround and let me know whether it works in your scenario:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.ExportToPdfCommandName)
    {
        RadGrid1.MasterTableView.AllowFilteringByColumn = false;
        if (!RadGrid1.ExportSettings.IgnorePaging)
            RadGrid1.Rebind();
    }
}

Note that this will work when using the build-in command buttons or a custom button with ExportToPdf command. If this is not the case, you have to move that code in the corresponding handler (Button_Click) for example.

Regards,
Daniel
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Russell
Top achievements
Rank 1
answered on 15 Feb 2012, 05:33 PM
Daniel,
That workaround works successfully for me.  I'm able to use a GridDateTimeColumn with the Export to PDF.
Thank you much.
0
Markus
Top achievements
Rank 2
answered on 29 Aug 2012, 02:39 PM
In my case the problem was that I used a div to align a button in the CommandItemTemplate. Changed that to a span and it workd.

Just in case someone else runs into that problem :-)

<CommandItemTemplate><span style="float:right;">
<asp:Button ID="DownloadPDF" runat="server" Width="80px" CommandName="ExportToPdf"
CssClass="pdfButton" Text="drucken" BorderStyle="None" BackColor="#BFDBFF"/>
</span>
            </CommandItemTemplate>

Markus
0
Ashish
Top achievements
Rank 1
answered on 22 Jul 2015, 09:28 AM

////////////////////////// Default.aspx page

 

 <asp:ImageButton ID="imgbtnDownloadPDF" runat="server" OnClick="btnExportToPdf_Click"
                ImageUrl="~/images/Download.png" ToolTip="Click Here To Download" Style="margin: 10px;">
            </asp:ImageButton>

<telerik:RadGrid ID="rgShowResultDetails" runat="server" AutoGenerateColumns="false"
                    Skin="Metro" AllowPaging="false" AllowSorting="false" GridLines="Horizontal"
                    ShowFooter="false" OnItemDataBound="rgShowResultDetails_ItemDataBound" OnItemCommand="rgShowResultDetails_ItemCommand">
                    <ExportSettings IgnorePaging="true" OpenInNewWindow="true" ExportOnlyData="true">
                        <Pdf PageHeight="210mm" PageWidth="297mm" DefaultFontFamily="Arial Unicode MS" PageTopMargin="45mm"
                            BorderStyle="Medium" BorderColor="#666666">
                        </Pdf>
                    </ExportSettings>
                    <MasterTableView PageSize="1" TableLayout="Auto">
                        <Columns>
                            <telerik:GridBoundColumn DataField="LoginName" HeaderText="Login Name" Visible="false">
                                <ItemStyle HorizontalAlign="Center" CssClass="left" />
                                <HeaderStyle HorizontalAlign="Center" CssClass="left"></HeaderStyle>
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn UniqueName="ResultDetails">
                                <ItemTemplate>
                                    <div style="border-color: Orange; border: 10px solid #f60; padding: 0px; min-height: 100px;
                                        overflow: hidden; background: url(../images/ScoreCardImage.jpg) no-repeat #fff;
                                        position: absolute;">
                                        <div>
                                            <div style="width: 50%; float: left; height: 250px;">
                                                <img src="../images/KVLogo.png" style="padding: 60px 20px 20px; width: 320px;" />
                                            </div>
                                            <div style="width: 50%; float: right; height: 180px; text-align: center; padding-top: 70px;">
                                                <asp:Label ID="lblAssessmentForTestName" runat="server" Style="text-transform: uppercase;
                                                    color: darkred; font-size: 50px; text-align: justify;"></asp:Label>
                                            </div>
                                        </div>
                                        <h3 style="clear: both;">
                                            <img src="../images/ScoreCardText.png" style="margin-top: 20px;" alt="" /></h3>
                                        <table style="border: 1px solid #000; margin-bottom: 10px; width: 99%; margin-top: 10px;
                                            margin-left: 5px; margin-right: 5px;">
                                            <tr>
                                                <td>
                                                    User Name:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblUserAnswerShitUserName" runat="server"></asp:Label>
                                                </td>
                                                <td>
                                                    Test Name:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblUserAnswerShitTestName" runat="server"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Date of Birth:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblUserAnswerShitDateOfBirth" runat="server"></asp:Label>
                                                </td>
                                                <td>
                                                    Test ID:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblUserAnswerShitTestID" runat="server"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Email ID:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblUserAnswerShitEmailId" runat="server"></asp:Label>
                                                </td>
                                                <td>
                                                    Test Date & Time:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblUserAnswerShitDateAndTime" runat="server"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Contact Number:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblUserAnswerShitContactNumber" runat="server"></asp:Label>
                                                </td>
                                                <td>
                                                </td>
                                                <td>
                                                </td>
                                            </tr>
                                        </table>
                                        <asp:GridView ID="grdResultDetails" runat="server" AutoGenerateColumns="false" PageSize="5"
                                            AllowPaging="true" OnRowDataBound="grdResultDetails_RowDataBound" Style="margin-left: 5px;
                                            margin-right: 5px;">
                                            <HeaderStyle BackColor="#555353" ForeColor="White" Font-Bold="true" Height="10" HorizontalAlign="Center" />
                                            <PagerStyle HorizontalAlign="Center" />
                                            <AlternatingRowStyle BackColor="#f5f5f5" />
                                            <Columns>
                                                <asp:BoundField DataField="TotalNoOfQuestion" HeaderText="Total No. of Questions"
                                                    ItemStyle-HorizontalAlign="Center" ItemStyle-Width="200" />
                                                <asp:BoundField DataField="TotalNoOfAttemptedQuestions" HeaderText="Total No. of Attempted Questions"
                                                    ItemStyle-HorizontalAlign="Center" ItemStyle-Width="200" />
                                                <asp:TemplateField HeaderText="Total Score Achieved" ItemStyle-HorizontalAlign="Center"
                                                    ItemStyle-Width="200">
                                                    <ItemTemplate>
                                                        <asp:Literal ID="lblTotalScoreAchieved" runat="server" Text='<%# Eval("TotalScoreAchieved") %>'
                                                            Visible="false"></asp:Literal>
                                                        <asp:Label ID="lblTotalScoreAchievedFinial" runat="server" Width="70px"></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Total Score Achieved in %" ItemStyle-HorizontalAlign="Center"
                                                    ItemStyle-Width="200">
                                                    <ItemTemplate>
                                                        <asp:Literal ID="lblTotalNoOfQuestion" runat="server" Text='<%# Eval("TotalNoOfQuestion") %>'
                                                            Visible="false"></asp:Literal>
                                                        <asp:Label ID="lblTotalScoreAchievedInPercentage" runat="server" Width="70px"></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                            </Columns>
                                        </asp:GridView>
                                        <asp:GridView ID="grdResultDetails2" runat="server" AutoGenerateColumns="false" PageSize="5"
                                            AllowPaging="true" Style="margin-left: 5px; margin-right: 5px;">
                                            <HeaderStyle BackColor="#555353" ForeColor="White" Font-Bold="true" Height="10" HorizontalAlign="Center" />
                                            <PagerStyle HorizontalAlign="Center" />
                                            <AlternatingRowStyle BackColor="#f5f5f5" />
                                            <Columns>
                                                <asp:BoundField DataField="TotalNoOfQuestion" HeaderText="Total No. of Questions"
                                                    ItemStyle-HorizontalAlign="Center" ItemStyle-Width="200" />
                                                <asp:TemplateField HeaderText="Total No. of Attempted Questions" ItemStyle-HorizontalAlign="Center"
                                                    ItemStyle-Width="200">
                                                    <ItemTemplate>
                                                        <asp:Label ID="lblTotalScoreAchievedFinial2" runat="server" Width="70px" Text="0"></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Total Score Achieved" ItemStyle-HorizontalAlign="Center"
                                                    ItemStyle-Width="200">
                                                    <ItemTemplate>
                                                        <asp:Label ID="lblTotalScoreAchievedFinial2" runat="server" Width="70px" Text="0"></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Total Score Achieved in %" ItemStyle-HorizontalAlign="Center"
                                                    ItemStyle-Width="200">
                                                    <ItemTemplate>
                                                        <asp:Label ID="lblTotalScoreAchievedInPercentage2" runat="server" Width="70px" Text="0"></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                            </Columns>
                                        </asp:GridView>
                                        <table style="border: 1px solid #000; margin-bottom: 10px; float: right; margin-top: 10px;
                                            width: 275px; margin-left: 5px; margin-right: 5px;">
                                            <tr>
                                                <td>
                                                </td>
                                                <td>
                                                </td>
                                                <td>
                                                    Passing % Cut Off<span>:</span>
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblPassingPercentageCutOff" runat="server"></asp:Label>%
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                </td>
                                                <td>
                                                </td>
                                                <td>
                                                    Result<span>:</span>
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblResult" runat="server" Text="Pass"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                </td>
                                                <td>
                                                </td>
                                                <td>
                                                    Proficiency Level<span>:</span>
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblProficiencyLevel" runat="server"></asp:Label>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                        </Columns>
                    </MasterTableView>
                </telerik:RadGrid>

 ////////////////////// Default.cs page

protected void btnExportToPdf_Click(object sender, EventArgs e)
        {
              rgShowResultDetails.MasterTableView.ExportToPdf();

        }​

 

After That Show This massage

System.InvalidCastException: Unable to cast object of type 'Telerik.Web.Apoc.Layout.BlockArea' to type 'Telerik.Web.Apoc.Layout.AreaContainer'.
  at Telerik.Web.Apoc.Fo.Flow.BlockContainer.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.TableCell.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.TableRow.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.AbstractTableBody.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Table.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area, Region region)
  at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Pagination.PageSequence.Format(AreaTree areaTree)
  at Telerik.Web.Apoc.StreamRenderer.Render(PageSequence pageSequence)
  at Telerik.Web.Apoc.Fo.FOTreeBuilder.EndElement()
  at Telerik.Web.Apoc.Fo.FOTreeBuilder.Parse(XmlReader reader)

0
Daniel
Telerik team
answered on 27 Jul 2015, 08:18 AM
Hello Ashish,

I would recommend that you try to remove the width/height of all div elements.
Let me know whether this helps.

Regards,
Daniel
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Eric Krauska
Top achievements
Rank 1
Answers by
Eric Krauska
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Russell
Top achievements
Rank 1
Daniel
Telerik team
Markus
Top achievements
Rank 2
Ashish
Top achievements
Rank 1
Share this question
or