如何在网格视图中设置过滤器和日期范围过滤器 [英] How to set filter and date range filter in Grid view

查看:100
本文介绍了如何在网格视图中设置过滤器和日期范围过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友.....


我需要使用filter选项来过滤gridview选项.

并在两个日期之间搜索数据.

如何为该

设置方案

每个数据源控件(SqlDataSource,ObjectDataSource ...)都具有 FilterExpression 属性.
要应用过滤器,您需要这样的内容:

 字符串 filteringExpression = 字符串 .Format( 日期> ='{0}'AND日期< ='{1} 23:59:59'",dateFrom. ToString(" ),dateUntill(" ));

yourDataSource.FilterExpression =筛选表达式; 



并要删除过滤器,必须将数据源控件的FilterExpression设置为null.

 yourDataSource.FilterExpression = ; 


过滤是使用BindingSource完成的.过滤器属性.请参见 MSDN


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

解决方案

Every data source control (SqlDataSource, ObjectDataSource...) has FilterExpression property.
To apply filter you need something like this:

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.

yourDataSource.FilterExpression = null;


Filtering is accomplished using the BindingSource.Filter property. See MSDN


这篇关于如何在网格视图中设置过滤器和日期范围过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆