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

The Most Basic Implementation

6 Answers 125 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 28 Dec 2012, 12:23 PM
This is my first time to use Telerik reporting and I just upgraded from Visual Web Developer Express to VS 2012.

I have a web application project.

I've created a single report, bound to a sql data source, no parameters. I can preview the report and see all the data.
Report name: trpt01 - which creates a trpt01.cs and trpt01.resx file.

I've added a reportviewer to the page named rptview.

I have a button on the page and it runs the code to display the report "trpt01" in rptview.

I see examples using UriReportSource and InstanceReportSource. This seems very simple but I cannot get it to run.

Telerik.Reporting.UriReportSource ur = new Telerik.Reporting.UriReportSource();
ur.Uri = "trpt01.cs";
rptview.ReportSource = ur;
rptview.RefreshReport();

If I change ur.Uri to a name I know does not exist.. ie: "abc" or "abc.cs" - the reportviewer gives a "Generating Report" message. I've left it running and it continued for several minutes. If I give it the name "trpt01.cs" it runs and returns a "Data at the root level is invalid. Line 1, position 1." error message.

What am I missing? How do I refer to a report that I have in the root of my project?

Thanks.

6 Answers, 1 is accepted

Sort by
0
Matthew
Top achievements
Rank 1
answered on 28 Dec 2012, 12:48 PM
Solved... the report definition is a class.... got it.

Report rpt = new trpt01();
Telerik.Reporting.InstanceReportSource ir = new Telerik.Reporting.InstanceReportSource();
ir.ReportDocument = rpt;
rptview.ReportSource = ir;
rptview.RefreshReport();

And now onto more fun.
0
Ankita
Top achievements
Rank 1
answered on 08 Mar 2017, 07:19 AM

Hello,

I m trying to use mentioned code to bind viewer. but it shows error

My reporting version is Telerik.Reporting R1 2017. I have a web application project.

Report name: Report1- which creates a Report1.cs and Report1.resx file.

reportviewer name: reportViewer1

 

"Cannot implicitly convert type 'Telerik.Reporting.InstanceReportSource' to 'Telerik.ReportViewer.Html5.WebForms.ReportSource'"

 

 

0
Stef
Telerik team
answered on 09 Mar 2017, 02:05 PM
Hi,

The type of the report source must be considered with the type of the viewer and the format of the report (XML, TRDX|TRDP file, run-time instance or a class generated by VS Report Designer). The general purpose of the ReportSource object is to let you specify which report to be displayed, regardless the report format, and what values to be passed to the report's ReportParameters collection.

An example, in case you use the HTML5 WebForms ReportViewer:
var clientReportSource = new Telerik.ReportViewer.Html5.WebForms.ReportSource();
clientReportSource.IdentifierType = IdentifierType.TypeReportSource;
clientReportSource.Identifier = typeof(ReportCatalog).AssemblyQualifiedName;//or <namespace>.<class>, <assembly> e.g. "MyReports.Report1, MyReportsLibrary"
clientReportSource.Parameters.Add("Parameter1", 123);
reportViewer1.ReportSource = clientReportSource;

For more details and examples, please go through How to: Set ReportSource for Report Viewers.

Regards,
Stef
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Lana
Top achievements
Rank 1
answered on 13 Jun 2017, 03:59 AM
Hi, I'm having the same issue as you and I didn't quite understand your solution. Can you kindly elaborate what do you mean by the report definition is a class? Thank you.
0
Lana
Top achievements
Rank 1
answered on 13 Jun 2017, 04:05 AM
Oh, I forgot to include using Telerik.Reporting. Now, it's solved
0
Stef
Telerik team
answered on 13 Jun 2017, 08:08 AM
Hi Lana,

By report definition I refer to reports designed with the available Report Designers, or generated in code or as XML. Depending on the way the report was created you should use the corresponding ReportSource that let the Reporting engine know how to process the report.

For web viewers, you need a client-side ReportSource, that is processed on the server into a server-side ReportSource.


I hope this helps.

Regards,
Stef
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Matthew
Top achievements
Rank 1
Answers by
Matthew
Top achievements
Rank 1
Ankita
Top achievements
Rank 1
Stef
Telerik team
Lana
Top achievements
Rank 1
Share this question
or