如何在asp.net中使用转发器控件比较两个日期 [英] How to compare two dates using repeater control in asp.net
本文介绍了如何在asp.net中使用转发器控件比较两个日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在运行模式中,转发器控制如下
In Run Mode Repeater control as follows
Course Name Amount CourseDate
RPST 450 29 APR 2014
RAFF 500 29 APR 2014
我有一个名为Submit的按钮。
当我点击提交按钮时我想验证RPST和RAFF日期不得与日期相同。
i需要RPST日期为2014年4月29日,RAFF日期为2014年4月30日中继控制。
为什么我可以使用c#在asp.net中验证。
例外输出如下
I have one Button called Submit.
When i click the Submit button i want to validate the RPST and RAFF date must not be same date.
i need the RPST date is 29 APR 2014 and RAFF date is 30 APR 2014 in repeater control.
for that how can i validate in asp.net using c#.
Excepted Output as follows
Course Name Amount CourseDate
RPST 450 29 APR 2014
RAFF 500 30 APR 2014
推荐答案
请参阅我对该问题的评论。如果你的C#代码中确实有一些日期,你可以使用为System.DateTime
类型定义的'=='运算符来比较它们。如果你有两个同一日期的时间点,显然,时间值仍然可以不同,所以你使用属性使它们相同(然后只有日期部分会影响比较) System.DateTime.Date
:
http://msdn.microsoft.com/en-us/library/system.datetime.date.aspx [ ^ ]。
最后,如果是这样的话发生在输入上你只有以某种格式表示日期/时间的字符串,你可以使用System.DateTime <之一将其解析为
DateTime
/ code>方法解析
,ParseExact
,TryParse
或TryParseExact
你会在这里找到:
http://msdn.microsoft.com/en-us/library/system.datetime.as px [ ^ ]。
-SA
Please see my comment to the question. If you really have some dates in your C# code, your can compare them using the '==' operator defined for the typeSystem.DateTime
. If you have two points in time with the same date, the time values, obviously, can still be different, so you make them the same (and then only date part will affect the comparison) by using the propertySystem.DateTime.Date
:
http://msdn.microsoft.com/en-us/library/system.datetime.date.aspx[^].
And, finally, if it so happens that on input you have just the string representing date/time in some format, you can parse it toDateTime
using one of theSystem.DateTime
methodsParse
,ParseExact
,TryParse
orTryParseExact
you will find here:
http://msdn.microsoft.com/en-us/library/system.datetime.aspx[^].
—SA
这篇关于如何在asp.net中使用转发器控件比较两个日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文