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

How to use reports in ASP web forms app

5 Answers 217 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Al
Top achievements
Rank 1
Iron
Iron
Iron
Al asked on 10 May 2016, 10:30 AM

Hi,
I have been through the docs so many times but I am really struggling to work out how to hang this together.

What I am hoping to achieve (using an in-app hosted report server as this appears to be the new, recommended method):
1. Desing reports using the standalone designer on my dev machine, pointing to my local sql server
2. Deploy the reports to a live client site and view the report in my aspx page, using a db connection configured in the client website.

What I have done so far:
1. Created a report on my dev machine which runs just fine in the standalone designer
2. Add a report viewer page to my app using the .NET template 'Telerik web Forms Report Viewer Form R2 2106'
3. This gave me a report viewer page, a Reports folder, and a ReportController class.
4. I dumped my trdp file into the \Reports folder.
5. I set <ReportSource IdentifierType="UriReportSource" Identifier="Report1.trdp"> in my report viewer page
6. Running the page, gives an error about database connection being incorrect and a whole bunch of other stuff.

What I don't get:
1. How does the report viewer form know where to find the REST service serving the report?
2. Is the ReportsController.cs all I need or do I need additional stuff to make the REST service work?
3. How do I switch the report database connection at run time?

Please help.

5 Answers, 1 is accepted

Sort by
0
Al
Top achievements
Rank 1
Iron
Iron
Iron
answered on 12 May 2016, 11:57 AM
Hey Telerik - pls help. I just need some pointers to docs and/or samples that do as explained.
0
Stef
Telerik team
answered on 12 May 2016, 04:15 PM
Hi Al,

Based on you description, the only missing step is to add a connection string entry in the web application's web.config file. The connection string entry must have the name of the connection string used in the report.

On configuring a SqlDataSource component you can save a connection string by name (it will be searched in the application's configuration file), or you can hard-code the connection string (it will be the same always).

If you have a scenario where the connection string should be changed at run-time, you can switch to an ObjectDataSouce component that allows you to use a custom data retrieval logic. The data access layer can be loaded in the Standalone Report Designer tool by extending the tool's configuration - Extending Report Designer (tutorials at the bottom).


About using the HTML5 Viewer, please check how it works in the overview help article. In your case you are using the HTML5 WebForms ReportViewer, which is a wrapper of the original JS/CSS/HTML widget. The wrapper renders in browser the Javascript object and registers some scripts at the end of the page (please consider this if you will Ajaxify the page).
The viewer's properties can be configured from the VS Property grid, where the VS item template provides the viewer with some default settings.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Al
Top achievements
Rank 1
Iron
Iron
Iron
answered on 01 Jun 2016, 08:34 AM

Hi Stef,

Thanks for the reply.I managed to get the report working just fine when using an sqlDataSource in the trdp and using the same name of connection string that I have in my web.config. I can't quite wrap my head around having a dynamic connection string though (I am not sure what to do with your comments re: 'Extending Report Designer' and using 'ObjectDataSource' component).

In my web app I have no connection string at all in web.config. The parameters are stored in a separate file that is read and converted into an sql connection string and an entity framework connection string ie. what I have available is an sql connection object and/or an entity context object. Is there not an easy way that I can just set the datasource of the trdp report to one of these in either my page or in the controller at runtime?

BTW I think I am using the straight html viewer, not the asp wrapper. Not sure how or why that is.

0
Accepted
Nasko
Telerik team
answered on 03 Jun 2016, 12:35 PM
Hello Al,

The ObjectDataSource will allow you to retrieve data from a custom data retrieval method in your application. You can set the connection string or use your connection object inside this method and retrieve all of the required data, then return it to the report. Please refer to the provided help articles on the topic.

Regards,
Nasko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Al
Top achievements
Rank 1
Iron
Iron
Iron
answered on 06 Jun 2016, 09:25 AM

Hi Nasko,

Thanks, I have managed to extend the designer to use my custom dll and can successfully preview the report in the designer (custom dll is in the same folder as the report designer exe).

I copied the tdrp into the /Reports folder of my site and set the ReportViewer's 'Identifier' property to the report name - it seems to find the report ok as it runs. Initially I saw no data but when I copied my custom dll into the website's 'bin' dir then all worked just fine.

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