Adding and Configuring the ReportViewer Controls

You can add one or more instances of a ReportViewer control to a Microsoft Windows or an ASP.NET application by dragging the control from the Data section of the Visual Studio Toolbox to a page or form in your application. You can use a smart tags panel and properties to configure the control and bind the report. You can also write code if you want to configure the control programmatically.

The ReportViewer control displays one report definition at a time. You can combine multiple instances of the control on the same page or form if you want to be able to view reports concurrently. You can also use a single instance of the control to host multiple reports as long as users will be displaying one report at a time. To use a single control to show a sequence of reports, you must write code that associates a report to the ReportViewer control instance that you want to use.

The ReportViewer controls work in either local processing mode or in remote processing mode.

In local processing mode, the control opens a report definition, processes it, and then loads it into the view area. In local processing mode, you can get the report definition from a .rdlc file on the file system, from a stream, or from an embedded resource in your application. For more information, see ReportPath, LoadReportDefinition, and ReportEmbeddedResource.

In remote processing mode, the control retrieves a fully processed report from a Microsoft SQL Server 2005 Reporting Services report server. In remote processing mode, the ReportViewer control serves two purposes: it is used as a viewer, and it provides support for interacting with a report. In remote processing mode, all data processing and rendering is performed on the report server. Remote processing requires pre-published reports. You can get the report from a stream or by specifying the URL of the report address. You cannot use .rdlc files in remote processing mode. For more information, see LoadReportDefinition, ReportServerUrl, and ReportPath.

Important

Remote processing mode requires a licensed copy of SQL Server 2005 Reporting Services. Remote processing is intended to support organizations that have a SQL Server Reporting Services report server and want to use that server in conjunction with the controls. A server solution provides better scalability and performance, and offers additional features such as subscriptions, caching, and more report output formats. It is important to note that there are some visual and functional differences introduced into a report as a result of remote processing. For more information about remote processing mode, see Configuring ReportViewer for Remote Processing and Deploying Reports and ReportViewer Controls.

How to Add and Configure a ReportViewer Control

  1. Add a Windows Form or Web page to your project.

  2. In graphical design mode, drag the ReportViewer control from the Toolbox to the form or Web page. The ReportViewer control is in the Data group of the Toolbox. The control includes a ReportViewer Tasks smart tags panel so that you can immediately select the report.

  3. In the ReportViewer Tasks smart tags panel, select tasks to add a report and configure the control. Specifying the report determines whether the control is configured for local or remote processing.

    • Click Design a new report to start Report Designer and create a report definition (.rdlc) file within your application. You can create new reports within your application that are processed locally on the client. To learn more about creating reports, see Creating Client Report Definition (.rdlc) Files.

    • Use Choose Report to select an existing report definition. You can choose a local report definition (.rdlc) file that is defined in the project or you can choose Server Report to select a report that is published on a SQL Server 2005 Reporting Services report server.

      Selecting a server report configures the control for remote processing. To select a server report, you must know the report server URL and the path to the report. The report path must start with a forward slash ( / ). To run the report, you must have permission on the report server to access the report. If you do not know the URL or report path, see your report server administrator. For more information about server reports, see Configuring ReportViewer for Remote Processing.

      Selecting an existing report definition (.rdlc) file configures the control for local processing. When choosing a report, you must choose an .rdlc file; you cannot specify a .rdl file even if one exists in your project. If you want to use an .rdl file, you must convert it. For more information, see Creating Client Report Definition (.rdlc) Files and Converting RDL and RDLC Files.

    • Click Dock in parent container to expand the view surface of the ReportViewer control so that it uses all of the available space in the form or page. This option is available with the Windows Forms control.

    • Click Rebind Data Sources to update data source bindings for data tables and business objects that are used in the report. This option is available after you select a report for the control. You need to rebind a data source if you modify a report data source or if you modify a databound report item outside of the graphical report design environment (for example, if you edit the XML directly).

  4. Select the ReportViewer control and open the Properties window.

  5. Set properties on the ReportViewer control to determine the visibility and availability of viewing areas. Use the reference documentation to learn about each property. For more information, see ReportViewer Properties. To learn about the ReportViewer toolbar, see Configuring and Using the ReportViewer Toolbar.

  6. Build or deploy the application to preview the report within the form or page.

See Also

Concepts

Using the ReportViewer Tasks Smart Tags Panel
Creating Client Report Definition (.rdlc) Files
Configuring ReportViewer for Local Processing
Configuring ReportViewer for Remote Processing
Configuring Subreports and Drillthrough Reports (Visual Studio Report Designer)
ReportViewer Web Server and Windows Forms Controls

Other Resources

Samples and Walkthroughs