日期检查在asp.net [英] date check in asp.net

查看:59
本文介绍了日期检查在asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我需要检查一下出生日期是否小于30/11/2007,而不是禁用一些文本框.
这是我尝试的代码


hi to all

i need to check that if date of birth is less than 30/11/2007 than i need to disable some textbox.
here is my code i trying


if (dtdates.Rows[0]["dob"].ToString() < "30/11/2007")  //if dob is before 30/11/2007 than disabling
                  {
                      Txt1.Enabled = false;
                      Txt2 = false;
                      Txt2 = false;

                  }


不能应用于<类型的操作数. string和string


cannot be applied to operands of type < string and string

推荐答案

进行日期比较而不是字符串比较.

试试类似的东西:
Do date comparison instead of string comparison.

Try something like:
if (Convert.ToDate(dtdates.Rows[0]["dob"]) < Convert.ToDate("30/11/2007"))  //if dob is before 30/11/2007 than disabling 
{
                        Txt1.Enabled = false;
                        Txt2 = false;
                        Txt2 = false;
 
}


这篇关于日期检查在asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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