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

Report Book help needed

7 Answers 317 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Andy Green
Top achievements
Rank 1
Andy Green asked on 12 Oct 2009, 10:26 AM
Hi

I'm trying to get multiple reports to display in a ReportBook control.

Each report uses the same parameter (JobPlan_ID) but I cant see there the ReportBook merges the params and where I can set them.

I am trying the approach shown below, but I keep getting Object reference not set errors on the line assigning the paramter.

Dim reportBook As ReportBook = TryCast(Me.ReportViewer.Report, ReportBook)

Dim
Frontsheet_Report As New JobPlan_Frontsheet()
Frontsheet_Report.ReportParameters(
"JobPlan_ID").Value = Session("Jobplan_ID")
reportBook.Reports.Add(Frontsheet_Report)

Dim
Notes_Report As New JobPlan_Notes()
Notes_Report.ReportParameters(
"JobPlan_ID").Value = Session("Jobplan_ID")

reportBook.Reports.Add(Notes_Report)

 
I have gone through the help files and searched the site for Reportbook, and none of the examples quite fits.

Andy

7 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 13 Oct 2009, 02:59 PM
Hi Andy Green,

The Report property of the report expects Telerik.Reporting.IReportDocument which can be either a report book or a single report. If you receive null reference exceptions in the reportBook.Reports.Add() method, then most likely the ReportViewer is not bound to a ReportBook and returns single report. Debug your code carefully and see where does the error occur exactly.

All the best,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Andy Green
Top achievements
Rank 1
answered on 14 Oct 2009, 08:54 AM
The problem was this line:
Dim reportBook As ReportBook = TryCast(Me.ReportViewer.Report, ReportBook)
the value of reportBook was null, and I couldn't get it to work.

I've gone away from trying to create this in code behind, and I have now created it all in markup.

My report book now shows all my reports, but they are empty, how do I get my parameters into the reports, and how does the report book control merge the params into 1 set.

Each report has properties to set the param value as:

 

 
    Public Property JobPlan_ID() As Int32  
        Get  
            Return _JobPlan_ID  
        End Get  
        Set(ByVal Value As Int32)  
            _JobPlan_ID = Value 
        End Set  
    End Property 

 



ANdy
0
Steve
Telerik team
answered on 14 Oct 2009, 04:15 PM
Hi Andy,

Our advise is to review the ReportBook documentation that elaborates on how it works and also review our ReportBook demo report to see how it is implemented.

Greetings,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Andy Green
Top achievements
Rank 1
answered on 15 Oct 2009, 10:55 AM
I've gone through chunks of the docs again, and what is apparent is that most of what I want to do you only show examples with a built in datasource, I'm having to use a dataclass.

Unfortunately your examples dont show how to link the reportbook to a report with properties, or if it does I'm missing it.

This senario might be shown in the videos, but I cant view them, it's our web rules block all web media - yours included.

Thanks for your help till now, but it looks like I'm going to have to re think how I do this.

Andy

0
Steve
Telerik team
answered on 15 Oct 2009, 04:18 PM
Hello Andy,

The type of datasource you use to bind the report or the way you bind the report is not relevant (as long as the datasource is supported) in this case. The way you set the values for the report parameters is not relevant either and whether report parameters from two or more reports would be combined in a report book depends entirely on the Name and Type of the params. If they are the same, then they are considered equivalent and are displayed as a single parameter. So if we have to answer your question directly:

My report book now shows all my reports, but they are empty, how do I get my parameters into the reports, and how does the report book control merge the params into 1 set.

The reportBook would simply combine the reports into one IReportDocument and if the reports are empty, then their counterpart in the report book would be empty as well. You get the report parameters into the reportBook by simply having the parameters in your regular reports. I've explained the merging in the first paragraph.

Sincerely yours,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Andy Green
Top achievements
Rank 1
answered on 16 Oct 2009, 06:56 AM
Thanks Steve

My problem is that I dont have parameters declared in my reports, I'm passing the parm in the code behind, that is why its not available.

    Private Sub JobPlan_Frontsheet_NeedDataSource(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.NeedDataSource  
 
        Dim fs As New CPSMDAL.JobPlan  
        Dim fsDT As DataTable = fs.JobPlanReport_Frontsheet(Job_Plan_ID)  
        TryCast(sender, Telerik.Reporting.Processing.Report).DataSource = fsDT 
 
    End Sub 

I guess this is the wrong approach. I think the way forward (unless you have any better ideas) is to add datasources to the reports and do it that way ignoring the data classes, the downside is that this data access will be different to the rest of the site (and every other app we support)

Andy
0
saba homa
Top achievements
Rank 1
answered on 11 Jan 2010, 01:13 PM
Hi Steve,
Could you please help me,I am trying to learn Telerik Reporting.But I can not use from storedprocedure.
I can not bind database fields to chart too.
Regards,
             Saba
Tags
General Discussions
Asked by
Andy Green
Top achievements
Rank 1
Answers by
Steve
Telerik team
Andy Green
Top achievements
Rank 1
saba homa
Top achievements
Rank 1
Share this question
or