sgray128 10/30/2014 8:51:25 AM

Replacing the data source at run time

My forays into Telerik Reporting continue. I'm developing reports by dropping a SQLDataSource onto the design surface and configuring a stored procedure.

The code below shows how to replace the stored procedure at runtime


'create report instance
Dim report As New MyReport()
'set the report's data source
report.DataSource = GetReportData()
'get the nested data item and set its DataSource
Dim nestedDataItem = DirectCast(report.Items.Find("table1",True)(0), Telerik.Reporting.Table)
nestedDataItem.DataSource = GetTableData()
'display the report
Dim IRS As New Telerik.Reporting.InstanceReportSource()
IRS.ReportDocument = report
'send parameters' values if needed
'the ReportSource.Parameters collection is mapped by key to the report's ReportParameters collection
reportViewer1.ReportSource = IRS