Multiple Web Part consumer connection points

Discussion in 'ASP .Net' started by =?Utf-8?B?TWFyYyBXb29sZnNvbg==?=, May 31, 2007.

  1. 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.ConnectionProvider("Provides ML
    Object", "ProviderWebPartMLObjectProvider")]
    public Controls.IMLObject IMLObjectProvider()
    {
    return this;
    }

    and the ConsumerWebPart consumer is something like:

    [System.Web.UI.WebControls.WebParts.ConnectionConsumer("IMLObject
    Consumer","ConsumerWebPartMLObjectConsumer",AllowsMultipleConnections=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="ProviderWebPartEntityProvider"></asp:WebPartConnection>
    </StaticConnections>
    </asp:WebPartManager>

    The setup above works fine for the single connection, but if I try to add
    another <asp:WebPartConnection> to 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
    =?Utf-8?B?TWFyYyBXb29sZnNvbg==?=, May 31, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. senglory
    Replies:
    0
    Views:
    320
    senglory
    Aug 25, 2004
  2. Gatwick
    Replies:
    0
    Views:
    346
    Gatwick
    Aug 31, 2004
  3. Tony Girgenti
    Replies:
    3
    Views:
    391
    Laurent Bugnion
    Sep 12, 2006
  4. Patrick Sannes
    Replies:
    1
    Views:
    495
    Patrick Sannes
    Jun 28, 2007
  5. Michael Fan
    Replies:
    2
    Views:
    129
    Michael Fan
    Jul 16, 2004
Loading...

Share This Page