views:

4956

answers:

4

I want to create a custom web part that has more than 1 filter web part and that can be connected to Report Viewer Web Part (Integrated Mode) at runt time/design time.

I searched a lot but could not find a way to have single web part that is a provider to more than 1 filters.

Say for example -

1. My Report accept 2 parameter Department and Region.  
2. I want to connect both parameter with single web part having two drop down (one for Department and one for Region)
3. Values from both the drop down should be passed to Department and Region
4. Report should be rendered in Report Viewer Web Part

Solution Tried so far

1. Create a web part that adds two custom drop down 
2. Custom Drop down class that Implements from ITransformableFilterValues
3. Have 2 Methods on the web pat each having ConnectionProvider Attribute and return instance of drop down control

Problem:

Even though 2 connection option is shown on my custom filter web part only one can be added For example - If I connect Filter1(custom web part) to Department then i am unable to connect it to Report Viewer web part again.

My web part have methods like this 

              *[ConnectionProvider("Departmet", "UniqueIDForDept", AllowsMultipleConnections = true)]          public ITransformableFilterValues ReturnCity()          {              return dropDownDepartment; // It implemets ITransformableFilterValues          } 

        [ConnectionProvider("Region", "UniqueIDForRegion", AllowsMultipleConnections = true)]          public ITransformableFilterValues ReturnMyRegionB()          {              return dropDownRegion; //It implemets ITransformableFilterValues          }* 

A: 

I did something similar. This might help point you in the right direction. I used data in a form library to create a detailed report. I used reporting services and connected to sharepoint using web services. http://server/_vti_bin/Lists.asmx. The report parameter I used was the item ID or GUID. Then I configured my report viewer. On the form library I used JavaScript to override the context menu to add "View Report". On the report page I used a Query String filter to grab the item ID out of the url.

Jordan Johnson
A: 

This is actually an inherit problem in ASP.

http://forums.asp.net/p/1118366/2646773.aspx

knight0323
A: 

Thanks!

But in the forum http://forums.asp.net/p/1118366/2646773.aspx they are talking about the limitation of consumer Web part can connect to single provider web part (a=>c & b =>c) but i want to achieve something differnet

One Web Part that act as multiple provider (A=>C but A act as more than 1 provider connection(region, country, department))

Some thing like s a User control that have multiple drop down and each drop down act as one provider.

Hope i am able to explain my problem. Any help is appreciated!

A: 

Hi

Not sure if you were able to fix your problem..

Actually I tried with AllowsMultipleConnections = true and it worked fine:

using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;

using Microsoft.SharePoint;


using aspnetwebparts = System.Web.UI.WebControls.WebParts;
using Microsoft.Office.Server.Utilities;
using wsswebparts = Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.Portal.WebControls;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using Microsoft.SharePoint.Utilities;

namespace FromMultiSource
{
    [Guid("a0d068dd-9475-4055-a219-88513e173502")]
    public class MultiSource : aspnetwebparts.WebPart
    {
        List<wsswebparts.IFilterValues> providers = new List<wsswebparts.IFilterValues>();
        public MultiSource()
        {
        }

        [aspnetwebparts.ConnectionConsumer("Multiple Source Consumer", "IFilterValues", AllowsMultipleConnections = true)]
        public void SetConnectionInterface(wsswebparts.IFilterValues provider)
        {
            this.providers.Add(provider);
            if (provider != null)
            {
                List<wsswebparts.ConsumerParameter> l = new List<wsswebparts.ConsumerParameter>();
                l.Add (new wsswebparts.ConsumerParameter ("Value", wsswebparts.ConsumerParameterCapabilities.SupportsMultipleValues | Microsoft.SharePoint.WebPartPages.ConsumerParameterCapabilities.SupportsAllValue));
                provider.SetConsumerParameters(new ReadOnlyCollection<wsswebparts.ConsumerParameter>(l));
            }
        }

        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            // TODO: add custom rendering code here.
            // Label label = new Label();
            // label.Text = "Hello World";
            // this.Controls.Add(label);
        }

        protected override void RenderContents(HtmlTextWriter writer)
        {
            base.RenderContents(writer);
            this.EnsureChildControls();
            foreach (wsswebparts.IFilterValues provider in this.providers)
            {
                if (provider != null)
                {
                    string prop = provider.ParameterName;
                    ReadOnlyCollection<string> values = provider.ParameterValues;
                    if (prop != null && values != null)
                    {
                        writer.Write("<div>" + SPEncode.HtmlEncode(prop) + ":</div>");
                        foreach (string v in values)
                        {
                            if (v == null)
                            {
                                writer.Write("<div>&nbsp;&nbsp;<i>&quot;(empty)&quot;/null</i></div>");
                            }
                            else if (v.Length == 0)
                            {
                                writer.Write("<div>&nbsp;&nbsp;<i>empty string</i></div>");
                            }
                            else
                            {
                                writer.Write("<div>&nbsp;&nbsp;" + v + "</div>");
                            }
                        }
                    }
                    else
                    {
                        writer.Write("<div>No filter specified (all).</div>");
                    }

                }
                else
                {
                    writer.Write("<div>Not connected.</div>");
                }

                writer.Write("<hr>");
            }
        }
    }
}