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

Report VS ReportSource

2 Answers 291 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
james
Top achievements
Rank 1
james asked on 23 Mar 2021, 01:32 AM

I want to set the DataSource parameters at Webforms runtime so I created a DataSource with the code below. Hos do I attached this to the report before setting the ReportViewer reportSource? I can create a Report object and set the DataSource but how do I assign it to the reportsource which is set to the viewer?

 

 Telerik.Reporting.SqlDataSource sqlDataSource = new Telerik.Reporting.SqlDataSource();
                sqlDataSource.SelectCommand = "SELECT * FROM VerifiedComponents WHERE ItemNumber = @ItemNumber";
                sqlDataSource.Parameters.Add("@ItemNumber", System.Data.DbType.String, "14545454545");         

 

  Telerik.ReportViewer.Html5.WebForms.ReportSource reportSource = new Telerik.ReportViewer.Html5.WebForms.ReportSource();
                reportSource.IdentifierType = Telerik.ReportViewer.Html5.WebForms.IdentifierType.TypeReportSource;
                reportSource.Identifier = typeof(Report1).AssemblyQualifiedName;             

              reportViewer1.ReportSource = reportSource;     

2 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 25 Mar 2021, 01:30 PM

Hi James,

When you assign a DataSource to the report you modify the report definition. This can be done only server-side, in a Custom ReportSource Resolver. You need to instantiate the report in the Resolve() method, and after changing the report definition instance to wrap it in an InstanceReportSource and return it to the Reporting engine.

On the client-side, in the Html5 Report Viewer, you need to use IdentifierType CustomReportSource. The Identifier that you set in the viewer's ReportSource is the string reportId that you receive in the Resolve() method of the resolver. You need to use it to identify the report that will be rendered.

Regards,
Todor
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
james
Top achievements
Rank 1
answered on 25 Mar 2021, 02:03 PM

Hi Todor,

Thanks for the reply. Basically I was just trying to set the SqlDataSource parameter with code and couldn't find the interface to do that. But I figured out how to tie the Report parameter to the SqlDataSource parameter in the designer so I got what I needed. 

 

 

Tags
General Discussions
Asked by
james
Top achievements
Rank 1
Answers by
Todor
Telerik team
james
Top achievements
Rank 1
Share this question
or