public virtual string ParameterName
{
get
{
return "Geographic Region";
}
}
[wsswebparts.WebPartStorage(wsswebparts.Storage.None)]
public virtual ReadOnlyCollection<string> ParameterValues
{
get
{
string[] values = this.GetCurrentlySelectedGeographies();
return values == null ?
null :
new ReadOnlyCollection<string>(values);
}
}
public string[] GetCurrentlySelectedGeographies()
{
String[] choices = new String[5];
bool anythingSelected = false;
// It's possible for the ParameterValues property to be accessed
// before CreateChildControls has been called, so ensure the
// Region List combobox has been created.
if (cblRegionList == null)
{
choices = null;
return choices;
}
for (int i = 0; i < cblRegionList.Items.Count; i++)
{
// Get the selected choices
if (cblRegionList.Items[i].Selected)
{
anythingSelected = true;
if (cblRegionList.Items[i].Text != "All")
{
choices[i] = cblRegionList.Items[i].Text;
}
else
{
choices = null;
return choices;
}
}
}
if (!anythingSelected)
choices = null;
return choices;
}
// Use the ConnectionProvider attribute to specify the method that
// the Web Part framework should call to allow us to return an instance
// of our ITransformableFilterValues interface.
[aspnetwebparts.ConnectionProvider("Region Filter",
"ITransformableFilterValues", AllowsMultipleConnections = true)]
public wsswebparts.ITransformableFilterValues
SetConnectionInterface()
{
return this;
}
protected override void RenderContents(HtmlTextWriter output)
{
this.EnsureChildControls();
RenderChildren(output);
}
}
在wssv3中,filter WebPart通过WebPart连接将筛选条件从一个WebPart(提供者WebPart)传递到另一个WebPart(消费者WebPart)。这使得我们可以编写更加成熟的应用,通过允许用户提供搜索或筛选的条件来整合2007 Microsoft Office system。(在接下来的系列文章中,将会有通过WebPart调用Excel Web Services的内容,请关注)