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 |
---|---|---|
|
Single item |
Form web part (cell provider), Image web part (cell consumer) |
|
Row of values |
List web part (row provider) |
|
List (table) of values |
List web part (list provider) |
|
A list filter |
Form web part (filter provider) |
|
Set of values as described by the web part |
None |
|
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:
In Visual Studio, choose Project â Add â New Item and select the Provider Web Part template.
Create a .dwp file for the web part.
Repeat for the the Consumer Web Part template.
Build the project.
Create a test web page and import the two web parts onto the page.
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.