How to Bind and Populate Data Objects in .NET Core 6

1 Answer 61 Views
.NET Core Binding Report Designer (standalone) Report Viewer - HTML5
Travis
Top achievements
Rank 1
Travis asked on 12 Aug 2024, 05:12 PM

I'm working to transition rdlc reports from .net 4 to .net 6 with telerik reporting, and trying to reuse or convert as much of the old system as I can

I've got a report created in the standalone report designer with the dataset that matches the old report, and I've got the report service configured

I would like to populate my dataset through a service method based on parameters passed from a previous screen. The issue is that I cannot see a way to pass a populated data set through the front end of the HTML5 report viewer, and the documentation on the site for the Form_Load methods use a reportViewer1 variable that seems to be a Microsoft web forms reportviewer control that has no contemporary in .net core

I've looked into the NeedDataSource and ItemDataBinding events as well as using a service method to return the populated dataset as the Object Data Source, however I cannot create a service without passing parameters as the .net core dependency injection model directs, and that creates errors with the report designer attempting to dynamically generate the service

It seems like the only path forwards is to scrap the Object Data Source and try to rewrite all report logic as stored procedures. Am I missing something? Is there a way that I can pass a populated DataSet to the report to use as the data source? Is there any way I can pass a singleton service instance to return the populated dataset?

1 Answer, 1 is accepted

Sort by
1
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Aug 2024, 01:41 PM

Hello, Travis,

Indeed, the ObjectDataSource needs a parameterless constructor to instantiate the business object, which prevents from injecting custom dependencies in the constructor. If you need to transfer JSON data to the viewer, I would recommend you to have a look at the following KB article which offers a downloadable report as well: How to set the content of JsonDataSource through report parameter.

Data Source components are used to connect data items to different types of data without writing any code: Connecting to Data Overview.

On one hand, the NeedDataSource event is a convenient approach to connect the report to your data when you find it impossible to do it at design time. On the other hand, the WebServiceDataSource component enables data items to display data located on a service in JSON format while using no code. The Web Service Data Source Wizard allows you to create a new or edit an existing WebServiceDataSource component. The WebServiceDataSource can take parameters: Using Parameters with the WebServiceDataSource Component.

The following help articles and video tutorials are useful for getting started experience and setting up the HTML5 ReportViewer: 

Using the HTML5 Report Viewer in an ASP.NET Core application in .NET 6, .NET 7, and .NET 8

Using the HTML5 Report Viewer with REST Service

How to set up a Telerik Reporting REST Service in .NET 5?

Setting up Telerik Html5 Report Viewer with external Telerik Reporting REST Service in .NET 5

If you are still facing any difficulties, it would be greatly appreciated if you can share with us a sample project with the report itself (.TRDP file) so we can have a closer look into the exact setup you need to convert. Once we get better understanding of the precise case we would be able to think about an appropriate solution and provide further assistance.

I hope you find this information helpful. Please, let me know if there is anything else I can assist you with.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Stay tuned by visiting our roadmap and feedback portal pages, enjoy a smooth take-off with our Getting Started resources, or visit the free self-paced technical training at https://learn.telerik.com/.
Tags
.NET Core Binding Report Designer (standalone) Report Viewer - HTML5
Asked by
Travis
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or