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
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
相关文章推荐
- sharepoint 2010 中添加webpart时引用dll一些问题及解决方法。
- SharePoint 2010部署WCF续 - feature event receiver实现自动部署
- SharePoint 2010 BCS - 简单实例(一)数据源加入
- sharepoint 2010 用timer job 实现列表评论次数
- WCF:使用启用声明的 WCF Web 服务作为 SharePoint 2010 外部内容类型(第4 部分,共 4 部分)
- SharePoint 2010文档库批量下载文档的实现
- Sharepoint 2010 Content Search Webpart
- Sharepoint 2010 之 WebPart
- SharePoint 2010:“&”作为SharePoint账号密码引起的错误
- 在linux系统下利用PC机实现路由转发的具体步骤
- [SPS2010]一些sharepoint的面试题
- XSLT实现XML作为数据源在web页面显示人口金字塔统计图
- SliverLight读取SharePoint的图片库作为数据源
- 一步一步SharePoint 2007之二十八:实现WebPart的单步调试
- js中将字符串转换成json--(//highcharts图表里data数据源必须是数组形势的[{name="test1"},{name="test2"}])
- SharePoint 2010 自定义Ribbon实现文档批量下载为Zip文件(转)
- android studio引用项目作为library的具体操作步骤。
- Sharepoint 2010 Form 身份认证的实现(基于AD)
- SharePoint 2010 自定义Ribbon实现文档批量下载为Zip文件
- RDLC 2010设计器的数据源无法找到静态类作为数据源