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

Bind an already calculated List of objects to a Report datasource

2 Answers 890 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nabil
Top achievements
Rank 1
Nabil asked on 22 Feb 2018, 08:40 AM

Good morning Telerik team ! In fact i come from the SSRS world, in wich I was able to simply pass an already calculated list of objects to the report datasource and I don't want to use the dataMember technique to recalculate the same list again because it takes a while !

-----------------------------------------------

This is an example when i use the rdlc report :*

 LocalReport lr = new LocalReport
            {
                ReportPath = reportPath
            };

           ReportDataSource rds = new ReportDataSource();
                rds.Name = "reportDs";
                rds.Value = my already calculated List of objects
                lr.DataSources.Add(rds);

-------------------------------------------------

Can you please help me on that because we need it so much and thanks in advance !

2 Answers, 1 is accepted

Sort by
0
Ivan Hristov
Telerik team
answered on 27 Feb 2018, 01:37 PM
Hi Nabil,

For such scenarios we recommend using the ObjectDataSource, which accepts a collection of entities/business objects and can be used by any data item - Report, Subreport, Table, Crosstab, Graph, Map.
Depending on the scenario, the collection can be persisted in a static variable, in the ReportResolver or in the report instance. The assignment of this collection is quite similar to the one used in SSRS - for example, if you use it in a WinForms report viewer, you can assign it right before previewing the report:
var report = new ListBoundReport();
report.DataSource = MyBusinessObject.GetData();
 
this.reportViewer1.ReportSource = new InstanceReportSource() { ReportDocument = report };
this.reportViewer1.RefreshReport();

The GetData() method of MyBusinessObject returns a ICollection<MyBusinessObject> to be used by the data items.

You can read more about the ObjectDataSource and its usage here:

ObjectDataSource component
How to: Bind to a BusinessObject
How to: Bind to a DataSet

Regards,
Ivan Hristov
Progress 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
-1
Nabil
Top achievements
Rank 1
answered on 28 Feb 2018, 11:28 AM
Thanks a lot for your response !
Tags
General Discussions
Asked by
Nabil
Top achievements
Rank 1
Answers by
Ivan Hristov
Telerik team
Nabil
Top achievements
Rank 1
Share this question
or