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

multiple datasources

1 Answer 278 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
JAMES
Top achievements
Rank 1
JAMES asked on 15 Mar 2016, 05:46 AM

in the official demo Dashboard.trdx report file, it defines two datasources:

1. yearDataSource

2. mainDataSource

 

I am trying to render the report as pdf with the ability to update the data source from the code (runtime), like this:

 

static void SaveReport(Telerik.Reporting.Report report, string fileName)
        {
            ReportProcessor reportProcessor = new ReportProcessor();

            Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource();
            instanceReportSource.ReportDocument = report;
            
            RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);

            using (FileStream fs = new FileStream(fileName, FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }
        }

 

 

it only allows me to set the report.DataSource, not sure how to update all the data sources (yearDataSource & mainDataSource).

 

Can I just pass a dataset with 2 tables (named "yearDataSource" & "mainDataSource")?

 

1 Answer, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 16 Mar 2016, 06:00 PM
Hi James,

You can iterate the report's Items collection and update all data items' DataSource properties at run-time. Please consider the example in Changing the connection string dynamically according to runtime data.


I hope this information is helpful.

Regards,
Stef
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
JAMES
Top achievements
Rank 1
Answers by
Stef
Telerik team
Share this question
or