The table on food products shows a simple data grid with unfiltered data displayed using ASP.NET.
Once this is done, add a control for the user to select what data to filter. For instance, add a TextBox so that the user can input a part of, say, a name to search for. Now drop into Design view and add the following code below the data source control:
When we filter data using the SearchExpression extender, the data is filtered by the text entered. Here we're filtering with the letters 'ch.'
This is a simple example of the QueryExtender that uses the SearchExpression control parameter. This filters the data coming from the LinqDataSource1 by querying the ProductName field to see if it Contains the keywords entered in the TextBox1 control.
Note that the DataFields parameter allows you to specify multiple database fields even ones not in the current table but joined to it. You can also specify whether the data should be contained anywhere, starts with or end with it. When you view the page, you can enter some characters into the textbox and submit the page. The QueryExtender will fill the GridView with the filtered results.
The RangeExpression filter lets you provide a minimum and maximum value for a field range to be filtered.
The PropertyExpression allows filtering based on properties of an element such as the checked property of a checkbox field.
These are not the only types of search you can do. You can have a RangeExpression that accepts a minimum and maximum to search for in a field, a PropertyExpression which allows you look for a particular property value of a field, a CustomExpression that lets you write code to do specific custom filtering and an OrderByExpression to sort the results. Take a look at the following QueryExtender snippet to see examples of each.
You can use these in combinations to create extremely rich advanced search pages without requiring to write tons of lines of code to parse and dynamically generate the SQL needed to return the results you want.
Integrate your work force and give a fight to your Competition.
Network with 2000 software professionals and create evangelists for your products.
About CIOL | Media Kit | Site Map | Contact Us | Help | Write to us | Jobs@CyberMedia | Privacy Policy
Copyright © CyberMedia India Online Ltd. All rights reserved. Usage of content from web site is subject to Terms and Conditions.