Share via


ICellConsumer Interface

The ICellConsumer interface enables a Web Part to communicate with a Web Part that implements the ICellProvider or IRowProvider interface to work with a single value item.

Microsoft.SharePoint.WebPartPages.Communication.ICellConsumer

Events

The following table shows the events of the ICellConsumer interface and a brief description of each.

Name Description
CellConsumerInit Initialization event. This event handler is of type CellConsumerInitEventHandler.

Public Methods

The following table shows the methods of the ICellConsumer interface and a brief description of each.

Name Description
CellProviderInit(object, Microsoft.SharePoint.WebPartPages.Communication.CellProviderInitEventArgs) Initialization event. This event handler is of type CellProviderInitEventHandler.
CellReady(object, Microsoft.SharePoint.WebPartPages.Communication.CellReadyEventArgs) Called after a cell changes such as when a cell is selected or updated. This event handler is of type CellReadyEventHandler.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.

Remarks

The ICellConsumer interface should be implemented in Web Parts that need to consume a single value from a provider part. The ICellConsumer part has the ability to send and receive initialization arguments from the provider part. Because a Web Part that implements the ICellConsumer interface can connect to both the ICellProvider and IRowProvider interfaces, it is a good choice for being the receiver of single value items. Connecting an ICellConsumer interface to an ICellProvider interface is a direct connection so no transformer dialog box will be displayed. To appropriately use the passed values, the consuming Web Part may need to be written with an understanding of the data being sent by the provider Web Part. When connecting an ICellConsumer interface to an IRowProvider interface, a transfomer dialog box will be displayed automatically, which allows an end user to map the column in the row to the appropriate cell. In this case, the consuming Web Part doesn't need to map the value between the parts because the end user will perform this mapping. However, this does require a user with a deeper understanding of the design of the Web Parts to form a correct mapping, and the output value of the provider part needs to be compatible with the input of the consumer part.

Example

The following code example shows a simple Web Part that implements the ICellConsumer interface and supports running its connections code only on the server (ConnectionRunAt.Server). This Web Part can be connected to another Web Part which implements either the ICellProvider or IRowProvider interface on the server. This Web Part's user interface displays a simple text box and label. When the Web Part receives a value from another connected Web Part, the value will be rendered within the text box.

There are 11 steps specific to making this Web Part class a connectable Web Part. These steps are numbered and commented in the code example.

The following code example shows a Web Part class that implements the ICellConsumer interface and supports running its connections code only on the client (ConnectionRunAt.Client). This Web Part can be connected to another Web Part that implements either the ICellProvider or IRowProvider interface on the client. This Web Part's user interface displays a simple text box with a label. When the Web Part receives a value from another connected Web Part, the value will be rendered within the text box.

There are 13 steps specific to making this Web Part class a connectable Web Part. These steps are numbered and commented in the code example.

For an overview of the steps of creating a connectable Web Part, see Creating a Connectable Web Part.

Requirements

Namespace: Microsoft.SharePoint.WebPartPages.Communication

Platforms: Microsoft Windows Server 2003

Assembly: Windows SharePoint Services (in Microsoft.SharePoint.dll)

Security: Code Access Security