Click here to Skip to main content
15,887,175 members
Articles / Web Development / ASP.NET
Article

Generate Filter String

Rate me:
Please Sign up or sign in to vote.
1.48/5 (6 votes)
15 Oct 2007 23.1K   165   11   1
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

C#
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

C#
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



Comments and Discussions

 
GeneralSuggestions Pin
wout de zeeuw15-Oct-07 2:46
wout de zeeuw15-Oct-07 2:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.