Question

I’m currently trying to use web part connections to connect an out the box List to my visual webpart. Now I can find lots of examples of connecting 2 custom web parts together using a user defined interface but am having trouble finding examples of the functionality I require.

Scenario 1 : Ability to add my Visual Web part to a list view and connect them so my WP is the consumer of the List and that when the user clicks/selects a row in the list view my web part would get sent the id of the item.

Scenario 2 : Ability to add my Visual Web part to a list display form and connect them so my WP is the consumer of the List item and the Id of the list item get passed to the WP when the form loads/displays.

Now I know that this is what I need to consume the data

[ConnectionConsumer("Parameter", AllowsMultipleConnections = false)]
    public void ThisNameDoesNotMatter(IWebPartParameters provider)
    {
        _provider = provider ;
    }

but unsure of whether I should be using the IWebPartParameters, IWebPartRow or the IFilterConsumer.

I guess I’m starting to wonder if this is even possible as I'm struggling to find any examples of this functionality.

Any help would be great.

Cheers Lee

Was it helpful?

Solution

Ok so I found what I was looking for partialy, below is the code that captures the Connection object

private IWebPartField _provider = null;
    [ConnectionConsumer("Parameter", AllowsMultipleConnections = false)]
    public void ThisNameDoesNotMatter(IWebPartField provider)
    {
        _provider = provider ;
    }

the IWebPartField Interface was what I was looking for to consume a value from anouther webpart (in my case a List column field). To get the Field I needed if my custom webpart is on the display form of the list I just get it from the query string.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top