$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
ListView Filtering in ASP.NET
Home > How to > ListView Filtering

Once a listview is added to your ASP.NET AJAX UI application, at times you might need to apply filtering functions to help you go through a large number of data, so that you can easily find what you want with higher efficiency.
In this tutorial, we will explain to you how to apply basic filtering for your Kettic listview control and then introduce to you some of the commonly used filter expression. You can either apply these built-in filter expressions directly or you can build your own according to your requirements.

How to Build ListView Filter Expression

Although Kettic listview control has already provides you with plenty of built-in featured filter expressions to fulfill basic needs, you might want to build some more on your own. In order to achieve that, you only need the designed filter expressions to Kettic Filter Expression collection and then it is done!
  • To build a new filter expression, you can create instances for it and then add to Filter Expression collection;
  • Alternatively, you can simply resort to the expression builder, which is relatively easier compared to the first method;
  • Or, you can do this programmatically with Visual C# or Visual Basic .NET sample codes.

ListView Built-In Filter Expression

In this section, we will provide you with a brief introduction for some of the basic predefined filter expressions to help you easily get started with Kettic ListView control filtering.
  • EqualTo: Using this filter expression, web developers can specify a field, and then input the value to be filtered on to a desired result;
  • NotEqualTo: If you use this filter expression, you should specify the value to be filtered on and corresponding field name to get the result;
  • GreaterThan: This filter expression is used to filter items from a field with value greater than the the value to be filtered on;
  • GreaterThanOrEqualTo: This filter expression is used to filter items from a field with value that is either greater than or equal to the filtering value;
  • LessThan: You can try this filter expression to get result that with a value that is less than the value to be filtered on;
  • LessThanOrEqualTo: Developers can apply filter expression when you want to get items that is either less than or equal to the value to be filtered on;
  • Contains: This is a commonly used filter expression which will get you the items that contains the value to be filtered on;
  • IsEmpty: Specify a field and this filter expression will get you items with empty value;
  • IsNotEmpty: Specify a field and this filter expression will get you items with value;
  • IsNull: When you intend to find out all the null fields you can utilize this filter expression;
  • IsNotNull: When you intend to find out all the fields which are not null, you can utilize this filter expression;
  • StartsWith: This is most widely used filter expression as it returns all the items in a certain field that starts with you input value;
  • EndsWith: This is another common filter expression as it returns all the items in a certain field that ends with your input filtering value;

Visual C# Sample for ListView Filtering

Below is a simple Visual C# demo for applying the built-in filter expressions provided by Kettic ListView control for ASP.NET AJAX. Please feel free to copy to your program for a test.
PerListView1.FilterExpressions.BuildExpression().EqualTo("field",1).Build();
PerListView1.FilterExpressions.BuildExpression().NotEqualTo("field",1).Build();
PerListView1.FilterExpressions.BuildExpression().GreaterThan("field",1).Build();
PerListView1.FilterExpressions.BuildExpression().GreaterThanOrEqualTo("field",1).Build();
PerListView1.FilterExpressions.BuildExpression().LessThan("field",1).Build();
PerListView1.FilterExpressions.BuildExpression().LessThanOrEqualTo("field",1).Build();
PerListView1.FilterExpressions.BuildExpression().Contains("field",1).Build();
ASP.NET AJAX UI Controls