I am new to sharepoint. I don't know if this is possible or not. I have two web parts, one has two values which I need to pass to the second web part. Is there any way doing that or I can only have one connection/ Thanks
I have two visual web parts. In Provider I have two dropdownlists which I need to pass the values to Consumer. Here is the code:
public interface IMyConnection { int AreaId { get; } int TopicId { get; } }
public class Provider : WebPart, IMyConnection
{
private Control control;
protected override void CreateChildControls()
{
control = Page.LoadControl(_ascxPath);
Controls.Add(control);
base.CreateChildControls();
}
public int AreaId
{
get { return 1; }
}
public int TopicId
{
get { return 2; }
}
[ConnectionProvider("TopicId", "TopicId", AllowsMultipleConnections = true)]
public IMyConnection SetTopicConnection()
{
return this;
}
[ConnectionProvider("AreaId", "AreaId", AllowsMultipleConnections = true)]
public IMyConnection SetAreaConnection()
{
return this;
}
}
public class Consumer : WebPart
{
private IMyConnection connection;
private Control control;
protected override void CreateChildControls()
{
control = Page.LoadControl(_ascxPath);
Controls.Add(control);
}
[ConnectionConsumer("TopicId", "TopicId", AllowsMultipleConnections = true)]
public void GetTopicConnection(IMyConnection theConnection)
{
connection = theConnection;
}
[ConnectionConsumer("AreaId", "AreaId", AllowsMultipleConnections = true)]
public void GetAreaConnection(IMyConnection theConnection)
{
connection = theConnection;
}
protected override void RenderContents(HtmlTextWriter writer)
{
if (connection != null)
{
//do work
}
base.RenderContents(writer);
}
}
When I try to set the connections, it doesn show both but only set the Topic connection.