Delen via


Report Viewer Web Part Programmability in SharePoint Integration

The Report Viewer Web Part is a ReportViewerWebPart server control, which contains a set of public application programming interfaces (API) that enables developers to create custom SharePoint applications. You can create custom Web Parts that supply report path and parameters to Report Viewer Web Part using Web Part connections. You can also embed the Web Part in a custom SharePoint Web Part page and customize it using the public API.

Connecting to Report Viewer Web Part with Custom Web Parts

The Report Viewer Web Part is a connection consumer to SharePoint Web Parts that implement IWebPartRow or IFilterValues. An IWebPartRow Web Part, such as the Documents Web Part can supply a report path to a Report Viewer Web Part when placed on the same Web Part page as the Report Viewer Web Part. Likewise, an IFilterValues Web Part, such as the Text Filter or the Choice Filter, can supply a report parameter to a Report Viewer Web Part when placed on the same Web Part page as the Report Viewer Web Part.

Implementing a Report Path Provider with IWebPartRow

To supply a report path to the Report Viewer Web Part through Web Part connections, do the following:

  1. Create a Web Part that implements the IWebPartRow interface.

  2. Add the Web Part to the same Web Part page as the Report Viewer Web Part.

  3. Connect your Web Part to the Report Viewer Web Part in the Web-based Web Part design user interface.

    Note

    You can only connect one IWebPartRow Web Part to the Report Viewer Web Part at a time, and you cannot connect both an IWebPartRow Web Part and an IFilterValues Web Part to the Report Viewer Web Part at the same time.

For your IWebPartRow Web Part to work properly with the ReportViewerWebPart, you must do the following in the GetRowData(RowCallback) method:

  • Invoke the callback method with a DataRowView object as the input parameter.

  • Make sure that the DataRowView object contains a column called "DocUrl" that contains the report path.

    Note

    The Report Viewer Web Part in the add-in for Office SharePoint Server 2010 also supports receiving the report path using the "FileRef" column.

Implementing a Report Parameter Provider with IFilterValues

A Web Part that implements IFilterValues can provide one parameter value to the Report Viewer Web Part. The parameter value sent to the Report Viewer Web Part is subject to the same restrictions placed on the report parameter as specified in the report definition, such as data type, valid values, and so on

To supply a report parameter to the Report Viewer Web Part, do the following:

  1. Create a Web Part that implements the IFilterValues interface.

  2. Add the Web Part to the same page as the [T:Microsoft.ReportingServices.SharePoint.UI.WebParts.ReportViewerWebPart.]

  3. Connect your IFilterValues Web Part to the Report Viewer Web Part in the Web-based Web Part design user interface.

    Note

    You can connect multiple IFilterValues Web Parts to the Report Viewer Web Part at a time. However, you cannot connect both an IWebPartRow Web Part and an IFilterValues Web Part to the Report Viewer Web Part at the same time.