按日期选择器过滤gridview [英] Filter gridview by datepicker

查看:75
本文介绍了按日期选择器过滤gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要有关在Visual Studio 2010的gridview中过滤日期列的帮助.这是我的代码:

Hello all,

I need help regarding filtering a date column in the gridview in Visual Studio 2010. This is my code:

Me.HVseznamBindingSource.Filter = "Date = #" & Me.Datetimepicker1.Value & "#" 


但是,当我运行此代码时,gridview返回0条记录.

我不知道那会是什么.我已经更改了所有方面,表格,DateTimePicker的日期格式.简短,冗长,自定义.但是,它仍然给出相同的结果,或得到#" & Me.Datetimepicker1.Value & "#"格式错误的代码错误.

有人会检查此代码或向我指出如何按日期过滤gridview的正确方向.

预先感谢您对任何人的帮助!

[原标题]
通过datepicker过滤gridview? (Visual Studio)


修改:(从答案中删除)

感谢您的答复.
我找到了代码:


But, when I run this code the gridview returns 0 records.

I do not know what it could be. I have changed the date format on all fronts, table, DateTimePicker. Short, Long, custom. However, it still gives the same results, or getting code error that #" & Me.Datetimepicker1.Value & "#" is wrong format.

Would someone check this code or point me in the right direction on how to filter gridview by date.

Thank you in advance for your help to anyone!

[original title]
Filter gridview by datepicker??!! (Visual Studio)


Modification: (Moved from answer)

Thanks for your replies.
I have found the code:

Me.HVseznamBindingSource.Filter = "Date = '" & Me.Datetimepicker1.Value.date & "'"



它可以用于Access或Sql服务器...
最终修改



It can be used for Access or Sql server...
End Modification

推荐答案

您使用MS Access,Sql Server还是什么作为数据源?无论如何,我都会尝试:
(a)更改日期定界符,对Access使用#定界符,对Sql Server使用单引号(''),
(b)将等号(=)运算符与其他运算符(例如filter = " between ''2010/01/01 00:00'' and ''2010/12/31 23:59'' ";),
(c)暂时忘记日期时间选择器,并用硬编码日期替换以调试问题,
(d)使用标准的数据库日期时间格式(yyyy/mm/dd hh:mm:ss)(例如2010/12/31 23:59).

我希望这会有所帮助,
祝你好运.
Do you use MS Access, Sql Server or what as a data source? In any case, I would try to:
(a) change date delimiter, use # delimiter for Access and single quote ('') for Sql Server,
(b) change equal (=) operator with between operator (eg. filter = " between ''2010/01/01 00:00'' and ''2010/12/31 23:59'' ";),
(c) forget date time picker for a while and replace with hard coded dates to debug the problem,
(d) use standard database date time formats (yyyy/mm/dd hh:mm:ss) (eg. 2010/12/31 23:59).

I hope this helps,
Good luck.


这篇关于按日期选择器过滤gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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