Connecting Parts

A web part that can exchange data with another web part is called connectable. You create a connectable part by implementing one of the SharePoint connection interfaces in your web part class. Since there are two sides to any connection, there are two interfaces for each type of connection: a provider and a consumer. The interfaces are described in Table 9-5.

Table 9-5. Web part connection interfaces

Interface pair

Use to share

Example

ICellProvider,

ICellConsumer

Single item

Form web part (cell provider), Image web part (cell consumer)

IRowProvider,

IRowConsumer

Row of values

List web part (row provider)

IListProvider,

IListConsumer

List (table) of values

List web part (list provider)

IFilterProvider,

IFilterConsumer

A list filter

Form web part (filter provider)

IParametersInProvider,

IParametersInConsumer

Set of values as described by the web part

None

IParametersOutProvider,

IParametersOutConsumer

Set of values as described by the web part

None

Creating a Simple Connection

The Web Part Templates for Visual Studio includes templates for ICellProvider and ICellConsumer web parts. To add connectable web parts to an existing web part library project:

  1. In Visual Studio, choose Project → Add → New Item and select the Provider Web Part template.

  2. Create a .dwp file for the web part.

  3. Repeat for the the Consumer Web Part template.

  4. Build the project.

  5. Create a test web page and import the two web parts onto the page.

  6. Choose Modify Shared Page ...

Get Essential SharePoint now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.