Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Generate Filter String

0.00/5 (No votes)
15 Oct 2007 2  
Generate Filter String as per user requirment
Screenshot - filter.jpg

Introduction

Here I introduce one filter control base on query

Using the Code

In this code I am create one usercontrol so

1) Register a usercontrol

<%@ Register TagName="Filter" TagName="Filter" TagPrefix="UC" 
    Src="~/filtercontrol/FilterControl.ascx" %>

2) Pass appropriate data

in page load method

you have to pass one two dimension string array

 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) use function

On button click even use the function for gating filter string and clear the filter criteria

    protected void Button1_Click(object sender, EventArgs e)
    {
        Label1.Text = filter1.filterstring();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        filter1.blankfilter();
    }<o:p />

i am apply this user control for filter the record in recordset , view state etc.

you can also change the code for your requirment

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here