2010-09-17 52 views
4

我使用Sharepoint,嘗試連接具有多個參數的Web部件。ITransformableFilterValues具有兩個或更多參數的接口[SharePoint WebParts]

我的問題是如何從custome web部件傳遞多個參數到另一個參數。

我能夠通過在自定義Web部件中實現ITransformableFilterValues接口來傳遞一個參數,我想要做的就是傳遞多個參數(例如MyIndex2)。

// 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; 
    } 

感謝您的幫助。抱歉我的英語。

回答

3

創建一個實現ITransformableFilterValues接口(而不是在你的Web部件類實現它)一類

class FilterValues : ITransformableFilterValues 
{ 
... 
} 

在您的主要網站的一部分已經

FilterValues _fitler1; 
FitlerValues _filter2; 

(很明顯,你將需要設置他們也是)

添加方法返回不同的過濾器例如

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

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

確保報告參數處於可見模式。它爲我工作。試試看

感謝 維韋克

0

要解決你的代碼修改如下:

[aspnetwebparts.ConnectionProvider("Season", "idSeason", AllowsMultipleConnections = true)] 
public wsswebparts.ITransformableFilterValues SetConnectionSeason() 
{ 
    return filterValuesSeason; 
} 

[aspnetwebparts.ConnectionProvider("Category", "idCategory", AllowsMultipleConnections = true)] 
public wsswebparts.ITransformableFilterValues SetConnectionCategory() 
{ 
    return filterValuesCategory; 
} 
0
filterValuesYear = new FilterValues("Year", ddlYear.SelectedValue); 
     filterValuesQuarter = new FilterValues("Quarter", ddlQuarter.SelectedValue); 

     [ConnectionProvider("Year", "performance_year", AllowsMultipleConnections = true)] 
    public ITransformableFilterValues SetConnectionYear() 
    { 
     return filterValuesYear; 
    } 

    [ConnectionProvider("Quarter", "performance_monthly", AllowsMultipleConnections = true)] 
    public ITransformableFilterValues SetConnectionQuarter() 
    { 
     return filterValuesQuarter; 
    } 

建立的每一件事情的WebPart後呈現,我看到兩個連接可用。 嘗試發送連接至ReportViewerWebPart窗口打開,讓空參考後(我嘗試創建對象時,它需要的,但它不工作)

感謝 -Samar