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

ReportSource Property

2 Answers 572 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jerry Jansen
Top achievements
Rank 1
Jerry Jansen asked on 12 Jun 2012, 06:31 PM
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 Answers, 1 is accepted

Sort by
0
IvanY
Telerik team
answered on 13 Jun 2012, 03:50 PM
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 >

0
Jerry Jansen
Top achievements
Rank 1
answered on 13 Jun 2012, 05:04 PM
Thanks IvanY 
I finally figured it out.
Tags
General Discussions
Asked by
Jerry Jansen
Top achievements
Rank 1
Answers by
IvanY
Telerik team
Jerry Jansen
Top achievements
Rank 1
Share this question
or