Pro SQL Server 2012 Reporting Services

(sharon) #1

CHAPTER 9  RENDERING REPORTS FROM .NET APPLICATIONS


Now you have a foundation for using the report viewer control with Windows Forms applications.
This chapter's examples have implemented URL access in a web browser control as well as the Report
Viewer control for rendering the reports, providing you with multiple choices for integrating reporting
into your Windows Forms applications. You’ve made your viewer a lot more user friendly by using SSRS
2012’s SOAP-based API to access the rich functionality of SSRS to retrieve the available report
parameters and possible values. This allows you to create a more familiar and responsive Windows-
based user interface for your users.
You can also render reports using the Report Server Web service directly. However, you lose the
functionality of features such as the report toolbar with its built-in navigation and export functionality.
This means you have to create these on your own if you use the other web service for rendering.

Building the Report Viewer in ASP.NET


With Visual Studio, you are also given the option to use the Report Viewer control in an ASP.NET
application. This can give you the flexibility to develop custom reporting applications that do not have to
be distributed to users or updated on an end user’s machine each time a patch is deployed. Users can
access your custom application through any standard Web browser, and any modifications can be
transparent to your end users.
You will use many of the same concepts and methods in this project that were used in the forms
application that we have previously built. Start by creating a new ASP.NET Web Application project.
Name this project SSRS_WebViewer and choose a location for your source files.

 Tip Don’t worry if you do not have IIS available on your development machine. Using the debugging features of
Visual Studio will allow you to see your ASP.NET application in a Web browser.

You will now have a new Web application project with a Default.aspx file created for you. Open this
Web page and add five controls to the layout of the page:


  • DropDownList: You will use this drop-down list to hold the names of the reports
    returned from the SSRS 2012 Web service. Name it reportList.

  • Button: This will be used to trigger the rendering of a report in the Report Viewer.
    Name it renderReport and change the display text to Render.

  • Horizontal Rule: You will use a horizontal rule in the form just to separate the top
    controls from the Report Viewer.

  • Report Viewer: You will render the reports stored on the SSRS 2012 server with this
    control. Name it reportViewerWeb.

  • ScriptManager: It is a requirement of using the ReportViewer control that you
    include a ScriptManager control on your page. It makes sure that all the required
    prerequisite code is included in the page that is needed by the ReportViewer.


Once you have the controls on the page and sized to fit your layout, add an on-click action to the
button that was just created. You can do this by viewing the page in design mode and double-clicking
the button, just like a Windows form button. Don’t worry about the contents of the function that gets
Free download pdf