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 System.Web.UI.WebControls.IWebPartRow or Microsoft.SharePoint.WebPartPages.IFilterValues. An System.Web.UI.WebControls.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 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.

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 System.Web.UI.WebControls.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 System.Web.UI.WebControls.IWebPartRow Web Part to the Report Viewer Web Part at a time, and you cannot connect both an System.Web.UI.WebControls.IWebPartRow Web Part and an Microsoft.SharePoint.WebPartPages.IFilterValues Web Part to the Report Viewer Web Part at the same time.

For your System.Web.UI.WebControls.IWebPartRow Web Part to work properly with the ReportViewerWebPart, you must do the following in the System.Web.UI.WebControls.IWebPartRow.GetRowData(Microsoft.SharePoint.WebPartPages.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 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

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

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

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

  3. Connect your 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 Microsoft.SharePoint.WebPartPages.IFilterValues Web Parts to the Report Viewer Web Part at a time. However, you cannot connect both an System.Web.UI.WebControls.IWebPartRow Web Part and an Microsoft.SharePoint.WebPartPages.IFilterValues Web Part to the Report Viewer Web Part at the same time.