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
IRS.Parameters.Add("Parameter1",newvalue)
  
reportViewer1.ReportSource = IRS


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences