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

Creating reports by name

2 Answers 86 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Bob Bruce
Top achievements
Rank 1
Bob Bruce asked on 08 Jan 2010, 09:59 PM
Is there a way I can create a new instance of a rport using a variable containing the report name, such as:

rpt = new Telerik.Reporting.Report strRptName

We want to allow users to select reports for a report book and I would like to pass this data to the viewer as a list of report names.  Possible?

2 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 11 Jan 2010, 11:54 AM
Hi Bob Bruce,

As you might probably know, the Report property of the viewer expects the assembly qualified name of the Report type. Thus in order to instantiate a certain report from its name, you should construct the assembly qualified name (e.g. Report="ClassLibrary1.Report1, ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null") first and then pass that to the Report property of the viewer or add it to a report book e.g.:

string aqn = String.Format("ClassLibrary1.{0}, ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", DropDownList1.SelectedItem);
Type reportType = Type.GetType(aqn);
IReportDocument report = (IReportDocument)Activator.CreateInstance(reportType);
this.ReportViewer1.Report = report;


Kind regards,
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
Bob Bruce
Top achievements
Rank 1
answered on 11 Jan 2010, 12:49 PM
Thanks.  In trying this out, I may have misunderstood something.  My class library is Named BobsReportLibrary, and the report I want to call is named rptPartsList.  Can you give me an example using those names:
      
       Dim agn as string = string.empty
       agn= ????

Thanks again.
Tags
General Discussions
Asked by
Bob Bruce
Top achievements
Rank 1
Answers by
Steve
Telerik team
Bob Bruce
Top achievements
Rank 1
Share this question
or