Adding and Configuring the ReportViewer Controls

You can add one or more instances of a ReportViewer control to a Windows Forms or an ASP.NET application by dragging the control from the Reporting section of the 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 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 reports one 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 renders the report in 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 Reporting Services report server. In remote processing mode, all data processing and report processing is performed on the report server. Remote processing mode is typically used for pre-published reports, but you can also use remote processing for a report definition that you supply using a stream. For more information, see LoadReportDefinition, ReportServerUrl, and ReportPath.

Important

You cannot use .rdlc files in remote processing mode. Remote processing mode requires a licensed copy of SQL Server 2008 or later 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. 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 form to a .NET Framework 3.5 or 4.0 project.

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

    The web.config file is automatically updated with the HTTP handler for the ReportViewer control. For more information, see Web.config Settings for ReportViewer.

    Note

    To use the ReportViewer control in a Web form, you must also add a ScriptManager control to your page. From the Toolbox window, in the AJAX Extensions group, drag a ScriptManager control to the design surface above the ReportViewer control.

  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 the Report Wizard 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 2008 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. When referencing a report on a report server in native mode, the report path starts with a forward slash ( / ); when referencing a report on a report server in SharePoint integrated mode, the report path is a fully qualified URL. For example:

      Native mode: /Adventureworks 2008 Sample Reports/Company Sales 2008

      SharePoint integrated mode: http://MyServer/sites/MySite/MyLibrary/Adventureworks 2008 Sample Reports/Company Sales 2008.rdl

      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. For more information, see Creating Client Report Definition (.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
ReportViewer Web Server and Windows Forms Controls

Other Resources

Samples and Walkthroughs
Configuring Subreports and Drillthrough Reports (Visual Studio Report Designer)