Pro SQL Server 2012 Reporting Services

(sharon) #1
CHAPTER 9  RENDERING REPORTS FROM .NET APPLICATIONS

less common – but more powerful – control to integrate our SSRS reports into a Windows form or
ASP.NET project.


Building the Report Viewer Using a Report Viewer Control


Now, you’ll learn how you can use the Report Viewer control to render the same Employee Service Cost
report. Not only is it likely to be the most popular method for rendering server-based reports, but it also
includes the ability to render reports based on the RDL locally without a report server.
You can use the two Report Viewer controls: one for Windows Forms applications and one for
ASP.NET applications. These controls allow you to add rich reporting features to your Windows or
ASP.NET applications more easily than is possible using any other method. The controls offer the power
of the URL rendering method but make it easier to implement in your code because most options are
now set as properties on the Report Viewer control. In other words, you don’t need to include them in
the string that you pass in as the URL. Another main advantage of working with the controls is that you
get full IntelliSense support for all the options within the Visual Studio 2010 IDE.
Table 9-5 lists some of the key properties and methods of the Report Viewer controls.


Table 9-5. Sample Report Viewer Properties and Methods


Property/Method Description


ProcessingMode Determines whether the report is processed locally or by an
SSRS 2012 server.


ServerReport.ReportServerUrl Specifies the URL of the reporting server it will use to render a
report when in remote mode.


ServerReport.ReportPath Specifies the path to the specific report you want to render. Do
not include the report server URL as part of the path since it is
defined by ReportServerUrl.


LocalReport.ReportEmbeddedResource Specifies the name of the report to use. By default when you
add a local report (rdlc) to a project, Visual Studio 2010 sets the
report as an embedded resource. Other properties allow you to
point to a path on disk or even a stream for the report
definition.


LocalReport.DataSources.Add Specifies the method used to add a data source to the report.


RefreshReport Causes the report to be rendered.


 Note See the Visual Studio 2010 help for more information about the members of the Report Viewer control as


well as for information about a number of other properties, methods, and events that come with the Report Viewer


controls.

Free download pdf