您的位置:首页 > 其它

sharepoint 2010中将web part作为图表的webpart的数据源实现的一些具体步骤。

2011-08-30 16:44 375 查看
  首先要明白如何将一个webpart 连接到图表的webpart,这其实就是两个webpart 连接的问题。主要是找到一个接口为你写的webpart提供数据,在这里我使用的是IwebpartTable的这个接口。 在这个接口的实现的主要代码如下:

public class VisualWebPart1 : WebPart, IWebPartTable

{

DataTable _table = null;
public VisualWebPart1()
{
_table = new DataTable();
}

//在这里将你的控件添加进来。

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

//实现IwebpartTable的 Schema属性

public PropertyDescriptorCollection Schema
{
get
{
if (_table.DefaultView.Count == 0)
{
return null;
}
else
{
return TypeDescriptor.GetProperties(_table.DefaultView[0]);
}
}
}

//实现Iwebparttable 的方法

public void GetTableData(TableCallback callback)
{
callback(_table.Rows);
}
public void SetTable(DataTable dt)
{
this._table = dt;
}
[ConnectionProvider("Table", AllowsMultipleConnections = true)]
public IWebPartTable GetConnectionInterface()
{
return this;
}

}

如果要是在可视化webpart中实现此控件的话,主要是要将可视化中的值传到此程序中的_table中。 最后生成部署此webpart 连接到图表 webpart。

参考资料:http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.iwebparttable.gettabledata%28v=vs.80%29.aspx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: