Click here to Skip to main content
15,915,019 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi Friends.....


I need to filter the gridview options using filter option.

and search data in between two dates.

How can i set for that
Posted

Every data source control (SqlDataSource, ObjectDataSource...) has FilterExpression property.
To apply filter you need something like this:
C#
string filteringExpression = string.Format("Date >= '{0}' AND Date <= '{1} 23:59:59'",dateFrom.ToString("yyyy-MM-dd"),dateUntill("yyyy-MM-dd"));

yourDataSource.FilterExpression = filteringExpression; 


and to remove filter you must set FilterExpression of your data source control to null.
C#
yourDataSource.FilterExpression = null;
 
Share this answer
 
Filtering is accomplished using the BindingSource.Filter property. See MSDN
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900