ITransformableFilterValues interface with two or more parameters [SharePoint WebParts]

connectionsharepointweb-parts

I working with Sharepoint, and I try to connect web-parts with multiple parameters.

My question is how do I pass more than one parameter from a custome web part to another.

I am able to pass one parameter by implementing the ITransformableFilterValues interface in the custom webpart , what I want to do is pass more than one parameter (MyIndex2 for example).

    // Configure interface

    public bool AllowEmptyValue
    {
        get { return false; }
    }
    public bool AllowAllValue
    {
        get { return true; }
    }
    public bool AllowMultipleValues
    {
        get { return true; }
    }
    public string ParameterName
    {
        get { return "MyIndex"; }   // Name of provided parameter
    }
    public ReadOnlyCollection<string> ParameterValues
    {
        get
        {
            EnsureChildControls();               
            List<string> MyFilterValues = new List<string>();
            if (MyFilterValue != null)
            {
                MyFilterValues.Add(MyFilterValue); //Provided value for another web-part
            }                           

            ReadOnlyCollection<string> result = new ReadOnlyCollection<string>(MyFilterValues);
            return result;
        }
    }


    [ConnectionProvider("MyIndex", "UniqueIDForRegionConnection", AllowsMultipleConnections = true)]
    public ITransformableFilterValues SetConnection()
    {
        return this;
    }

Thanks for help. And sorry for my English.

Best Answer

Create a class that implements the ITransformableFilterValues interface (rather than implementing it in your web part class)

class FilterValues : ITransformableFilterValues
{
...
}

In your main web part have

FilterValues _fitler1;
FitlerValues _filter2;

(obviously you will need to set them up too)

Add methods to return the different filters e.g.

[ConnectionProvider("Filter 1", "UniqueIDForFilter1", 
AllowsMultipleConnections = true)]
public ITransformableFilterValues SetConnection()
{
    return _fitler1;
}

[ConnectionProvider("Filter 2", "UniqueIDForFilter2", 
AllowsMultipleConnections = true)]
public ITransformableFilterValues SetConnection2()
{
    return _fitler2;
}