Binding to different data sources in report and table

1 Answer 92 Views
Binding DataSource Object Table
Eli
Top achievements
Rank 1
Eli asked on 09 Oct 2023, 08:18 PM | edited on 09 Oct 2023, 08:24 PM

I have a report which binds to a dataSourceObject1. In that same report, I have a table at the bottom of the report (for something else I need to print along with the report) which binds to dataSourceObject2. However, when I try to print it, the report prints fine until it gets to the table, in which it says,

"An error has occurred while processing Table 'table1': An error has occurred while resolving 'objectDataSource2' data source: Object reference not set to an instance of an object."

Here is what is in my C# code for the data source that the report prints from:

Telerik.Reporting.ObjectDataSource objectDataSource1 = new Telerik.Reporting.ObjectDataSource();

objectDataSource1.DataMember = "PaymentReportResult";
objectDataSource1.DataSource = TransformReport(_paymentData);
objectDataSource1.Parameters.Add(new Telerik.Reporting.ObjectDataSourceParameter("search", typeof(ReportSearch), search));

 

I thought I could do the same with another datasource, adding it in the same way, however this does not work. Additionally, if I switch the dataSource of the table to the same as the report, it also fails. I figured that means I am missing something when it comes to specifically binding it to the table.

1 Answer, 1 is accepted

Sort by
0
Momchil
Telerik team
answered on 12 Oct 2023, 12:01 PM

Hello Eli,

The code you shared looks correct and I do not think that you are missing anything when it comes to binding the table to the second data source. Assuming that you have a valid ObjectDataSource object, binding it to the table should be a matter of assigning it to the table's DataSource property (see the Binding ObjectDataSource to a BusinessObject article).

For example:

table1.DataSource = objectDataSource2;

That said, it is still difficult for me to pinpoint the source of the issue with the available information.

If you do not mind sharing your report, I would be glad to take a closer look at it.  

Kind Regards,
Momchil
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
Binding DataSource Object Table
Asked by
Eli
Top achievements
Rank 1
Answers by
Momchil
Telerik team
Share this question
or