ReportSource Property

3 posts, 0 answers
  1. Jerry Jansen
    Jerry Jansen avatar
    47 posts
    Member since:
    Aug 2009

    Posted 12 Jun 2012 Link to this post

    Just upgraded telerik reporting to 6.1.12.611 and I don't understand how to use the ReportSource property in code behind.

    Here is my current section of code which worked in the previous version:

            If dtrReader.HasRows Then
                Dim dt As New DataTable
                dt.Load(dtrReader)
                ReportViewer1.Visible = True
                ReportViewer1.Report.Reports(0).DataSource = dt
                ReportViewer1.RefreshReport()
            End If

    and this line of code no longer works: 
    ReportViewer1.Report.Reports(0).DataSource = dt
    
    and gives the warning that the Report property is now obsolete. Please use the ReportSource property instead.
    
    I can not figure out how to use the ReportSource property. Can someone please show me how to use it?
    
    Thanks,
    
    
  2. IvanY
    Admin
    IvanY avatar
    417 posts

    Posted 13 Jun 2012 Link to this post

    Hello Jerry,

    Here is a sample code that can help you use the new InstanceReportSource with the ReportSource property:
    InstanceReportSource reportSource = new InstanceReportSource();
    reportSource.ReportDocument = new Report1();
    reportSource.ReportDocument.Reports.Where(rep => rep.Name == "ReportName").FirstOrDefault().DataSource = myDataSource;
    ReportViewer1.ReportSource = reportSource;

    In the example above new Report Book is created for example and the datasource of the first report is changed. After that the viewer uses the newly created InstanceReportSource.

    All the best,
    IvanY
    the Telerik team

    BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

  3. DevCraft banner
  4. Jerry Jansen
    Jerry Jansen avatar
    47 posts
    Member since:
    Aug 2009

    Posted 13 Jun 2012 Link to this post

    Thanks IvanY 
    I finally figured it out.
Back to Top