ObjectDataSource Disappearing and Report not displaying table rows as per data

2 posts, 0 answers
  1. Rajiv
    Rajiv avatar
    4 posts
    Member since:
    Jul 2014

    Posted 30 Jul 2014 Link to this post

    I have created a sample project here, please download it and let me know what is the issue?
    https://www.dropbox.com/s/98ufwhrgnj19bdw/SampleReportTest.zip

    I need help in generating a sample report can you please help?
    I create a design report file and assign it a ObjectDataSource where its datasource is a class.

    In my code behind, I give a datatable with the same fields as of the class to render on my report, but its just doesn’t display the rows? Any ideas what I might be doing wrong?

    See sample project from my dropbox link above. Also, note once I build the dataexplorer shows no fields/properties of the objectDataSource1.

    Rajiv 
  2. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 04 Aug 2014 Link to this post

    Hi Rajiv,

    In the provided demo you use a Table item, which is a data item having its own DataSource property. Thus at run-time you need to get the Table item from the report instance's Items collection and set its data source e.g.:
    // Creating and configuring the ObjectDataSource component:
             Telerik.Reporting.ObjectDataSource objectDataSource = new Telerik.Reporting.ObjectDataSource();
             objectDataSource.DataSource = tempdt; // GetData returns a DataTable
     
             // Creating a new report
             Report1 report = new Report1();
     
             (report.Items.Find("table1", true)[0] as Telerik.Reporting.Table).DataSource = objectDataSource;
     
             Telerik.Reporting.InstanceReportSource reportSource = new Telerik.Reporting.InstanceReportSource();
             reportSource.ReportDocument = report;
     
             reportViewer1.ReportSource = reportSource;
             reportViewer1.RefreshReport();


    More information about setting report's data at run-time is available in the Changing the connection string dynamically according to runtime data KB article.


    I hope the above information helps you.

    Regards,
    Stef
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top