By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,214 Members | 2,066 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,214 IT Pros & Developers. It's quick & easy.

Multiple Web Part consumer connection points

P: n/a
Hello,

I can't seem to find any information on how best to implement multiple
connections on a consumer web part and was wondering if anyone could point me
in the right direction.

I have three web parts: two containing grids of data (the providers) and one
containing item detail (the consumer). All of the web parts implement a known
interface to enable the connections, and the AllowsMultipleConnections
attribute is set to 'true' on the consumer connection point. The desired
behaviour is that when an item is selected in EITHER of the grids of data,
the information is correctly retrieved and displayed in the connected item
detail web part.

Both providers implement their connections (in C#) along the following lines:

[System.Web.UI.WebControls.WebParts.ConnectionProvi der("Provides ML
Object", "ProviderWebPartMLObjectProvider")]
public Controls.IMLObject IMLObjectProvider()
{
return this;
}

and the ConsumerWebPart consumer is something like:

[System.Web.UI.WebControls.WebParts.ConnectionConsu mer("IMLObject
Consumer","ConsumerWebPartMLObjectConsumer",Allows MultipleConnections=true)]
public void IMLObjectConsumer(Controls.IMLObject MLObject)
{
if (MLObject != null)
{
SomeUniqueCode = MLObject.UniqueCode;
}
else
{
// throw some exception
}
}

I was originally connecting the web parts in the codebehind but have since
moved the declarations into the WebPartManager as follows:

<asp:WebPartManager ID="WebPartManager" runat="server">
<StaticConnections>
<asp:WebPartConnection ID="ThisConnection"
ConsumerID="ConsumerWebPart" ConsumerConnectionPointID="MLObjectConsumer"
ProviderID="ProviderWebPart"
ProviderConnectionPointID="ProviderWebPartEntityPr ovider"></asp:WebPartConnection>
</StaticConnections>
</asp:WebPartManager>

The setup above works fine for the single connection, but if I try to add
another <asp:WebPartConnectionto connect the secondary provider with the
same consumer, only the 'last' connection specified actually connects
properly, populating the desired data. Strangely enough, analysing the
execution order in the page's trace, I can see that the 'first' connection's
provider is called, followed by TWO consumptions by the consumer, even though
the data actually retrieved is from the 'last' provider in the
StaticConnections list.

I hope the above makes sense, as typing out the problem long-hand doesn't
really seem to to me! Any pointers?

Thanks,

Marc
May 31 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.