In SharePoint, a web part can be 'connected' to another web part to provide some information at run-time. The Provider web part pushes out the contracted information and the Consumer web part is set up to receive and consume the shared information.
Components of Connectable webparts
1) Interface: This custom interface will define the data to be shared from the Provider to the Consumer web part.
2) Provider web part: Implements a data interface - this interface is a definition of the data that will be shared from the Provider web part to the Consumer web part.
Provide a ConnectionProvider method which will expose the interfacing data to the Consumer web part.
3) Consumer web part: ConnectionConsumer method which will receive the interfacing data
Consume the interfacing data and provide enriching details to the user.
Steps for creating connectable web parts
1) Create an Empty SharePoint Project named ConnectedWebparts in Visual Studio 2010.
2) we add a new C# Interface code class and name it IUser.
3) Add a new web part named WPProvider in the project which will be the provider webpart. Make the changes as highlighted in the figure below.
4) Add a new web part named WPConsumer in the project which will be the provider webpart. Make the changes as highlighted in the figure below.
5) Build and Deploy the solution.
6) Add the Consumer webpart on the webpart page.
7) Add the Provider webpart on the webpart page.
8) Edit the Provider webpart and connect it to the consumer.
9) Now the 2 webparts have been connected to each other using the interface. In the provider webpart, type a username in the textbox and click "Send User". You can see the name is displayed in the consumer webpart as highlighted in the figure below.