1

我在使用日期选择器的页面中收到以下错误。无论插入哪一天,都会发生此错误:

1991 年 5 月 14 日。那是什么?今天是 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
4

1 回答 1

1

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

这是针对美国的,您需要根据您的要求进行设置。

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

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

于 2011-02-14T01:08:37.127 回答