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

How do I get a trdx report to display in a reportviewer in ASP.net?

1 Answer 115 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 19 Jan 2014, 03:16 AM
I must be dense or something, but for the life of me, can't figure out how to get a report viewer control to display a report.
I need to dynamically set the report location and SQL server connection string in the code behind. The reason for this is,
I want to call the report viewer from multiple areas in my asp.net application and populate it with different reports. Also, the
SQL connection string resides in the web.config and is encrypted. I need to decrypt the string before passing it on to the
report to use. Some reports are single layer and others have sub-reports in them.

So, how do I do this in the code behind of a web form? Source code example would greatly be appreciated.

Thanks!

1 Answer, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 21 Jan 2014, 04:52 PM
Hi Steve,

One approach is to create your own data access layer, where connection strings are decrypted and used to retrieve data based on permissions and other custom requirements. This layer with custom object can be used in report via ObjectDataSource/EntityDataSource/OpenAccessDataSource component. With this approach you can save further modifications on reports.

The other approach is to work with the selected report instance and its Items collection. Each  item can be accessed from the report instance and modified e.g:
Dim report As New MyReport()
DirectCast(report.DataSource, Telerik.Reporting.SqlDataSource).ConnectionString = NewString()
 
'get inner data item to change its data source as well
DirectCast(report.Items.Find("Table1", True)(0), Telerik.Reporting.Table).DataSource = GetNewData()
 
'get sub report
Dim subreport = DirectCast(myReport.Items.Find("subReport1", True)(0), SubReport)
 
'check the report definition to determine what is the used report source type for the SubReport item
Dim instanceRS = DirectCast(subreport.ReportSource, InstanceReportSource)
Dim subreportReport = DirectCast(instanceRS.ReportDocument, Report)
subreportReport.DataSource = GetData()

I hope this information helps you.

Regards,
Stef
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

Tags
General Discussions
Asked by
Steve
Top achievements
Rank 1
Answers by
Stef
Telerik team
Share this question
or