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

Error getting ReportHeader in code behind since upgrade

2 Answers 118 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Betsy
Top achievements
Rank 1
Betsy asked on 12 Jun 2012, 07:52 PM
I downloaded the latest reports version (6.1.12.611) and after fixing all the breaking code changes I now receive the following error when attempting to retrieve the reportheader section in code behind:
Unable to cast object of type Telerik.Reporting.Processing.PageSection to type Telerik.Reporting.Processing.Group

The commented out line was the original code which fails with the same error.  The error is thrown on any attempt to retrieve the Report.ReportHeader property (same error in the watch window).
Private Sub Table1_NeedDataSource(sender As Object, e As System.EventArgs) Handles Table1.NeedDataSource
  Dim tbl As Telerik.Reporting.Processing.Table = TryCast(sender, Processing.Table)
  Dim obj As Object = tbl.Report.ReportHeader
  ' Dim sect As Processing.ReportSection = TryCast(Processing.ElementTreeHelper.GetChildByName(tbl.Report, "ReportHeaderSection1"), Processing.ReportSection)
End Sub

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 15 Jun 2012, 03:00 PM
Hi Heather,

Currently the report always have at least one group. That group keeps the report sections. Thus in order to get the processing report header section from the report you have to use the recursive FindChildByName as shown in the following code snippet:

Private Sub Table1_ItemDataBound(sender As System.Object, e As System.EventArgs) Handles Table1.ItemDataBound
    Dim tbl As Telerik.Reporting.Processing.Table = TryCast(sender, Processing.Table)
    Processing.ElementTreeHelper.FindChildByName(tbl.Report, "reportHeaderSection1", True)
End Sub

Kind regards,
Peter
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

0
Betsy
Top achievements
Rank 1
answered on 15 Jun 2012, 04:53 PM
Thank you, that fixed the problem.
Tags
General Discussions
Asked by
Betsy
Top achievements
Rank 1
Answers by
Peter
Telerik team
Betsy
Top achievements
Rank 1
Share this question
or