2011-02-14 71 views
1

我在使用日期选择器的页面中出现以下错误。无论插入什么日子,都会发生此错误:使用日期字段提交表单时出错

14-Fev-1991。那是什么?今天是14-Fev,但不是1991年!我该怎么办?

String was not recognized as a valid DateTime. 

[FormatException: String was not recognized as a valid DateTime.] 
System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) +3211050 
System.DateTime.Parse(String s, IFormatProvider provider) +28 
System.ComponentModel.DateTimeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) +290 

[FormatException: 14-02-1991 is not a valid value for DateTime.] 
System.ComponentModel.DateTimeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) +452 
System.ComponentModel.DataAnnotations.RangeAttribute.SetupConversion() +626 
System.ComponentModel.DataAnnotations.RangeAttribute.IsValid(Object value) +38 

回答

1

您是否指定了默认的DateTimeFormat?希望它不使用美国格式

这是美国的,你需要根据你的要求设置它。

<configuration> 
    <system.web> 
     <globalization culture="en-US" uiCulture="de-DE"/> 
    </system.web> 
</configuration> 

这可能有助于进一步http://msdn.microsoft.com/en-us/library/ff647353.aspx

+0

它不工作。但为什么你认为这可以解决问题? 1991年无事可做,2月14日是今天。 – 2011-02-14 01:18:51