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

Telerik Reporting in a Website

1 Answer 40 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
headPropellerHead
Top achievements
Rank 1
headPropellerHead asked on 30 Apr 2012, 04:28 PM
For anyone else out there that's been struggling with getting dynamic connection strings working with Telerik Reporting in their Website (as opposed to Web Application), here's a great trick I finally figured out:

1.  Design the report according to the "Best Practices" in a seperate class project, using a data source that gives you a good representative sample of data.  Get the report looking just the way you want it.

2.  In your Website project, add a new page for displaying the report.

3.  Add a ReportViewer to the new page in your Website project (as described in the "How To: Add report viewer to a Web page" in the Telerik Reporting Q1 2012 documentation).

4.  In the Page_Load event of your new Website project page, instantiate a Report variable as described in the "Programmatic Control of Reports" section of the "Telerik Reporting Q1 2012" documentation (MyReport report = new MyReport();).

5.  Back in your seperate report class project, locate the .cs file for your report in the Solution Explorer and click the "+" symbol to expand it.  Open the .Designer.cs file you see there.

6.  In the Designer.cs file, copy the code within the InitializeComponent() priviate void.  Flip back over to your Website project and paste this code below the instantiation of your Report variable (in the Page_Load event of your new page).

7.  Everywhere in your pasted code you find "this", replace it with your Report variable.

8.  At the end of the report creation code you just pasted and tweaked, work your data access magic and set your report's .DataSource property to the DataTable that results from your data access magic.  (I have a custom class that executes stored procedures with connections strings that vary based on logged-in user.  The need to use this is what prompted this investigation and the solution I am describing here.)

9.  Set the .Report property of the ReportViewer on your new page to the Report variable.

Voila!  You now have a Telerik Reporting report, designed with the slick, easy-to-use Report Designer and tightly integrated into your Website project using the same data access methodology you used for your grids, pages, combo boxes, etc. used elsewhere in your Website project!

The posts in this forum have helped me save a lot of time over the years.  I hope this "gives back" and helps many others get through this sticky problem a lot quicker than I did.

Best,

- Russ

1 Answer, 1 is accepted

Sort by
0
Raja
Top achievements
Rank 1
answered on 16 Aug 2015, 07:03 PM
Hi! How to set the property of report viewer to variable
Tags
General Discussions
Asked by
headPropellerHead
Top achievements
Rank 1
Answers by
Raja
Top achievements
Rank 1
Share this question
or