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

Setting ReportViewer Report Name

3 Answers 199 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Pete
Top achievements
Rank 1
Pete asked on 04 Jun 2009, 09:22 AM
Hi, if I had two report names TotalReport1 and TotalReport2 in a combo box on a windows app, how can I show whichever one I want in a reportviewer at run time ? I had something like

ReportViewer testViewer = new ReportViewer();
testViewer.Report = ????

Do I have to populate the IReportDocument with the report name I choose in the combo box, if so does anyone know the syntax ?

Thanks a lot,

Pete.

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 04 Jun 2009, 11:31 AM
Hi Pete,

Using Activator.CreateInstance() would be the solution, as you need to pass the fully qualified report name to the viewer and not only a string reference. I've attached a sample project, that uses the same approach we're using for our demo reports. It is especially useful if you have no idea of the names and number of the reports.
If you're aware of the reports like in your scenario you can hardcode the values as explained in this forum thread.

All the best,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Pete
Top achievements
Rank 1
answered on 05 Jun 2009, 07:35 AM
Thanks Steve, this works fine now. Once again a great response.

Pete.
0
Pete
Top achievements
Rank 1
answered on 05 Jun 2009, 07:36 AM
The reflection solution seems to be a lot more efficient as well, as I can use this when I don't know the names of the reports as you said, excellent.

Pete.
Tags
General Discussions
Asked by
Pete
Top achievements
Rank 1
Answers by
Steve
Telerik team
Pete
Top achievements
Rank 1
Share this question
or