【发布时间】:2012-12-30 10:24:51
【问题描述】:
当我尝试转换为日期时间时出现以下错误。
字符串未被识别为有效的日期时间。
cost.b_date = DateTime.Parse(c_date.Text) ;//c_date.Text = 12/28/2012
那我试试
string date = string.Format("{0:yyyy-MM-dd}",c_date.Text);
cost.b_date = DateTime.Parse(date) ;
但我遇到了同样的异常,如何解决这个问题。
【问题讨论】:
-
可能是输入值错误。代码已成功运行以获得正确的值。
-
什么是
c_date?如果您有日历控件或日期时间选择器,只需选择日期,而不是原始文本..
标签: c# asp.net datetime linq-to-entities calendarextender