This example includes simple projects with report components (Document Viewer and Report Designer) for ASP.NET WebForms, ASP.NET MVC, ASP.NET Core, and Blazor Server (JavaScript-based) platforms. The project demonstrates how to create an object data source, bind it to a report, and restore the object data source when Document Viewer or Report Designer loads a report from a REPX file.
The ObjectDataSource serves as an intermediate layer between the report and the collection of data elements to which the report is bound. The advantage of ObjectDataSource
is that it is serialized in the report definition file (REPX). Otherwise, if you bind the report to a collection of custom objects, the data source information cannot be serialized, and you cannot restore the data source when you load the report from the REPX file.
Assign an ObjectDataSource
instance to the DataSource property of the report. The ObjectDataSource
instance specifies the type, constructors, methods, and properties of a custom object that creates a collection of data items. The custom object can contain a method that populates the collection of data items at runtime or retrieves data from any external data source.
The CustomWebDocumentViewerReportResolver
service in this example implements the IWebDocumentViewerReportResolver interface. The Document Viewer calls that before loading a report specified by name. The service creates a report, assigns the data source, and passes the report to the Document Viewer.
The CustomReportStorageWebExtension
service loads and saves a report specified by name in the Report Designer. The service is a ReportStorageWebExtension descendant.
The CustomObjectDataSourceConstructorFilterService
implements the IObjectDataSourceConstructorFilterService interface and filters the list of constructors available for the ObjectDataSource
in the Report Wizard and Data Source Wizard.
The ObjectDataSourceWizardCustomTypeProvider
service implements the IObjectDataSourceWizardTypeProvider interface and defines the list of data types displayed for the ObjectDataSource
in the Report Wizard and Data Source Wizard.
This example also demonstrates how to map a report parameter to the parameter used to filter data retrieved from the data source.
ASP.NET WebForms:
- EmployeesDataSource.cs (VB: EmployeesDataSource.vb)
- CustomWebDocumentViewerReportResolver.cs (VB: CustomWebDocumentViewerReportResolver.vb)
- CustomReportStorageWebExtension.cs (VB: CustomReportStorageWebExtension.vb)
- CustomObjectDataSourceConstructorFilterService.cs (VB: CustomObjectDataSourceConstructorFilterService.vb)
- ObjectDataSourceWizardCustomTypeProvider.cs (VB: ObjectDataSourceWizardCustomTypeProvider.vb)
- Global.asax.cs (VB: Global.asax.vb)
ASP.NET MVC:
- EmployeesDataSource.cs
- CustomWebDocumentViewerReportResolver.cs
- CustomReportStorageWebExtension.cs
- CustomObjectDataSourceConstructorFilterService.cs
- ObjectDataSourceWizardCustomTypeProvider.cs
- Global.asax.cs
ASP.NET Core:
- EmployeesDataSource.cs
- CustomWebDocumentViewerReportResolver.cs
- CustomReportStorageWebExtension.cs
- CustomObjectDataSourceConstructorFilterService.cs
- ObjectDataSourceWizardCustomTypeProvider.cs
- Startup.cs
Blazor:
- EmployeesDataSource.cs
- CustomWebDocumentViewerReportResolver.cs
- CustomReportStorageWebExtension.cs
- ObjectDataSourceWizardCustomTypeProvider.cs
- Startup.cs
- Register Types for Object Data Source Wizard (ASP.NET WebForms)
- Create the Object Data Source at Runtime (ASP.NET WebForms)
- Register Types for Object Data Source Wizard (ASP.NET MVC)
- Create the Object Data Source at Runtime (ASP.NET MVC)
- Register Types for Object Data Source Wizard (ASP.NET Core)
- Create the Object Data Source at Runtime (ASP.NET Core)
- Bind a Report to an Object Data Source in Blazor Applications
(you will be redirected to DevExpress.com to submit your response)