Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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));
    	}
    }
}
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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.

share|improve this answer
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 Jan 29 '10 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 –  Anders Rask Aug 28 '12 at 18:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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