Internet Explorer 7Internet Explorer 6.0IEVisual Basic 8 (2005)Windows 2003WebFormsWindows 2000Windows XP.NET 2.0C# 2.0中级开发Visual StudioWindows.NETVisual BasicASP.NETC#
生成过滤器字符串






1.48/5 (6投票s)
2007年10月15日

23550

179
根据用户要求生成过滤器字符串。

引言
这里我介绍一个基于查询的筛选控件
Using the Code
在这个代码中,我创建了一个用户控件,所以
1) 注册一个用户控件
<%@ Register TagName="Filter" TagName="Filter" TagPrefix="UC" Src="~/filtercontrol/FilterControl.ascx" %>
2) 传递合适的数据
在页面加载方法中
你需要传递一个二维字符串数组
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string[,] col = new string[2, 2];
col[0, 0] = "val";
col[0, 1] = "coltex1";
col[1, 0] = "val2";
col[1, 1] = "coltext2";
filter1._Collumname = col;
}
}
3) 使用函数
在按钮点击事件中使用该函数来获取筛选字符串并清除筛选条件
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = filter1.filterstring();
}
protected void Button2_Click(object sender, EventArgs e)
{
filter1.blankfilter();
}<o:p />
我将此用户控件应用于筛选记录集、ViewState 等中的记录。
你也可以根据你的需求修改代码