Report Viewer Web Part programmability in SharePoint integration

The Report Viewer Web Part is a 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.

Connect 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 T:Microsoft.SharePoint.WebPartPages.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 T:Microsoft.SharePoint.WebPartPages.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.

Implement a report path provider with IWebPartRow

Use the following steps to supply a report path to the Report Viewer Web Part through Web Part connections:

  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 T:Microsoft.SharePoint.WebPartPages.IFilterValues Web Part to the Report Viewer Web Part at the same time.

For your IWebPartRow Web Part to work properly with the T:Microsoft.ReportingServices.SharePoint.UI.WebParts.ReportViewerWebPart, you need to use the following steps for the GetRowData 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.

Implement a report parameter provider with IFilterValues

A Web Part that implements T:Microsoft.SharePoint.WebPartPages.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.

Use the following steps to supply a report parameter to the Report Viewer Web Part:

  1. Create a Web Part that implements the T:Microsoft.SharePoint.WebPartPages.IFilterValues interface.

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

  3. Connect your T:Microsoft.SharePoint.WebPartPages.IFilterValues Web Part to the Report Viewer Web Part in the Web-based Web Part design user interface.

    Note

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