Bind an already calculated List of objects to a Report datasource

3 posts, 0 answers
  1. Nabil
    Nabil avatar
    9 posts
    Member since:
    May 2016

    Posted 22 Feb Link to this post

    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. Ivan Hristov
    Admin
    Ivan Hristov avatar
    144 posts

    Posted 27 Feb Link to this post

    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
  3. Nabil
    Nabil avatar
    9 posts
    Member since:
    May 2016

    Posted 28 Feb in reply to Ivan Hristov Link to this post

    Thanks a lot for your response !
Back to Top