1

I'm writing a web part that needs to use connections for processing values relating to a business object called a "Program Entity". It is supposed to take in an ID provided by a connected web part, perform some processing, then spit out a 'token' for consumption by a different connected web part. The token is just the ID in another format.

I have the drop-down menu correctly displaying as follows:

Connections -> Send Program Entity Token To -> ...
            -> Get Program Entity ID From -> ...

When I select a web part in "Get Program Entity ID From", a dialog appears for me to choose a Filtered Parameter. However the dropdown of parameters is greyed out and just says "No Parameters". Note: the web part I'm trying to connect to is also custom and may not have been fully completed and tested for providing a value via a connection.

Is there anything that explains why I'm unable to set up a connection? Here is the code for my web part:

public class ProgramEntityTokenConverter : WebPart, ITransformableFilterValues
{
    public bool AllowAllValue
    {
    	get { return true; }
    }

    public bool AllowEmptyValue
    {
    	get { return false; }
    }

    public bool AllowMultipleValues
    {
    	get { return false; }
    }

    public string ParameterName
    {
    	get { return "ProgramEntityToken"; }
    }

    public ReadOnlyCollection<string> ParameterValues
    {
    	get { return new ReadOnlyCollection<string>(ConvertProgramEntityIDs()); }
    }

    [ConnectionProvider("Program Entity Token", "ProgramEntityToken", AllowsMultipleConnections = false)]
    public ITransformableFilterValues SetConnectionInterface()
    {
    	return this;
    }

    private IList<string> ConvertProgramEntityIDs()
    {
    	return null; // TODO
    }

    [ConnectionConsumer("Program Entity ID", "ProgramEntityID", AllowsMultipleConnections = false)]
    public void SetFilter(IFilterValues filterValues)
    {
    	if (filterValues != null)
    	{
    		EnsureChildControls();
    		List<ConsumerParameter> parameters = new List<ConsumerParameter>();
    		parameters.Add(new ConsumerParameter("ProgramEntityID", ConsumerParameterCapabilities.SupportsSingleValue));
    		filterValues.SetConsumerParameters(new ReadOnlyCollection<ConsumerParameter>(parameters));
    	}
    }
}

1 Answer 1

0

Now fixed by changing this line:

parameters.Add(new ConsumerParameter("ProgramEntityID", 
    ConsumerParameterCapabilities.SupportsSingleValue));

to this line:

parameters.Add(new ConsumerParameter("ProgramEntityID", 
    ConsumerParameterCapabilities.SupportsSingleValue | 
    ConsumerParameterCapabilities.SupportsAllValue));

The web part I was trying to connect to had the AllowAllValue property set to true which was clearly excluded by ConsumerParameterCapabilities.


As an aside, I also tried:

parameters.Add(new ConsumerParameter("ProgramEntityID", 
    ConsumerParameterCapabilities.SupportsMultipleValues | 
    ConsumerParameterCapabilities.SupportsAllValue));

... however the web part I'm connecting to has AllowMultipleValues set to false! It seems odd that ConsumerParameterCapabilities enforces possible connections according to AllowAllValue but AllowMultipleValues does not.

2
  • 1
    Isn't answering you own question a little like lobbing a basketball to yourself for a dunk? I'll admit, I asked one question hear, blogged the answer and then found someone had gotten answer credit for linking to my blog post.
    – Tom Resing
    Commented Jan 29, 2010 at 15:24
  • Adding an answer to your own Q gives you minimal (if any) credits, unless ofcourse you get upvoted because you did a good job :-) Both Q and A are good examples on how to ask and answer a question, and definately adds value to this site Commented Aug 28, 2012 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.