|  | 网站首页 | .Net研究 | 
您现在的位置: 程序员之路 >> .Net研究 >> 领域技术 >> SharePoint >> 文章正文
赞助商链接
频 道 导 航
.Net研究频道栏目导航
相 关 文 章
使用Web部件连接接口实现可以设置条件的过滤器           
使用Web部件连接接口实现可以设置条件的过滤器
作者:burnett 文章来源:不详 更新时间:2007-5-10 11:55:59

  在MOSS2007企业版里,默认提供了很多的过滤器,但是没有一种过滤器可以实现事先设定过滤条件,比如选择当前列表栏作为筛选条件,然后输入对应值,为了满足需求,使用了IFilterProvider接口实现一个Web部件。
   可以实现的功能:
   可以实现多条件候选值下的单一条件过滤。
   可以根据当前连接部件的视图自动适应栏,不需要使用者自己干预。

   前期的知识准备:
   需要有基本的Web部件的制作部署知识,需要了解Web部件连接的知识背景,这点在WSS SDK里写的很清楚,这个Web部件也是基于SDK写出来的。
   MOSS2007使用了新的接口,所以老的接口不在赞成使用,并且编译过程中会出现如下警告:

警告    18    “Microsoft.SharePoint.WebPartPages.Communication.ClearFilterEventHandler”已过时:“Use System.Web.UI.WebControls.WebParts.IWebPartParameters instead”    F:\毕业设计资料\Codes\Web Part1\Web Part1\SqlFilter\Sample.cs    31    46    Web Part1

但是本文为了兼容性,还是使用了老的接口版本。标准的IFilterProvider必须继承6个接口,但是有一些接口是可选的,所以我在这里省却一个。

using System;
using System.IO;
using System.Text;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.WebPartPages.Communication;

namespace MyCompany.Management.Employees
{
    [Guid(
"990c2459-2ec6-4794-931d-1e1a67acd723")]
    
public class SqlFilter :WebPart, IFilterProvider
    {
        
#region Web控件
        
private DropDownList ddl;
        
private Button btn_setfilter;
        
private Label lb_msg;
        
private TextBox tb_input;
        
private Button btn_clearfilter;
        
#endregion
        
#region 控制变量
        
private bool isConnected;
        
private string consumername;
        
private bool isClearFilterClicked;
        
private bool isSetFilterClicked;
        
private string errormsg;
        
/// <summary>
        
/// 存储列表的域,也就是数据库表中的列
        
/// </summary>
        private string[] fieldList=null;
        
/// <summary>
        
/// 存储列表域的显示名称
        
/// </summary>
        private string[] fielddspList=null;

        
/// <summary>
        
/// 下拉列表设定的过滤条件
        
/// </summary>
        private string filtercondition=string.Empty;

        
/// <summary>
        
/// 过滤条件表达式
        
/// </summary>
        private 

[1] [2] [3] [4] [5] [6] [7] 下一页

文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章: 没有了
  • .Net研究栏目导航
    网站频道导航