
Connecting Web Parts
❘
45
Build the solution to ensure it compiles. This is the rst step in connecting web parts. The interface
is structured, and now the provider web part needs to be created.
Creating the Provider Web Part
Continuing from the interface creation above, add a new item to your project again. This time select
Web Part from the SharePoint 2010 category. Modify the web part so that it also implements the
web part connection interface created in the previous section, as shown in Figure2-12. Give the le
a name and click Add. The code window appears.
FIGURE212: Implementing the interface
Because the provider web part implements the connection interface, the get methods need to be
defined within the web part class. In addition, because the values will be based on a drop-down list,
the drop-down control needs to be declared. The
ItemId is the underlying value of the drop-down
selection, and the
ItemTitle is the text of the selected item in the drop-down list. Therefore, these
properties should be implemented as follows.
private DropDownList _listDropDown;
public int ItemId
{
105054c02.indd 45 1/10/12 3:34 PM