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

Adding reports to ReportBook in Code-Behind

1 Answer 69 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
juststarting
Top achievements
Rank 2
juststarting asked on 06 Jul 2012, 08:15 PM
Hi,

I have successfully added a class with all my reports to my current project. However I do have a screen where the user can select which reports he/she want to print in a reportbook and save it into a pdf, and mail it to the user.

Currently the routine is as follows:
Select Case ReportSelected
    Case 1
          reportBook.Reports.Add(New Report1())
    Case 2
          reportBook.Reports.Add(New Report2())
    Case ....
End Select

This goes up to 40 at this stage.

What I want to know is if it is possible to this data in a database table and put the system through a loop to retrieve the report name from the database and add it to the reportbook?

Something like this :
While dbReader.Read()
     reportBook.Reports.Add(New dbReader("ReportName"))
End While

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 11 Jul 2012, 05:36 PM
Hello Sarel,

You can achieve your requirement in two ways. The first one is to keep in the report the serialized as XML reports or trdx report definitions created with the Report Designer. Then you can deserialize the XML report definitions and add them to the reportbook reports collection.

The other option is to keep in the database the AssemblyQualifiedName. Then you can instantiate the reports with reflection add them to the reportbook reports collection as shown in the following code snippet:

var reportType = Type.GetType(reportName);
var report = (IReportDocument)Activator.CreateInstance(reportType);
Greetings,
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 >

Tags
General Discussions
Asked by
juststarting
Top achievements
Rank 2
Answers by
Peter
Telerik team
Share this question
or