Asp.net mvc 5 使用datetime类时发生formatexception

Asp.net mvc 5 使用datetime类时发生formatexception,asp.net-mvc-5,entity-framework-6,entity-framework-5,formatexception,Asp.net Mvc 5,Entity Framework 6,Entity Framework 5,Formatexception,在我使用entity framework 6的ASP.NET MVC 5项目中,我有一个日期和时间属性,其类型为“DateTime”,但在转换为DateTime语句时有一个FormatException。要帮助您,我们需要更多信息。请分享您认为导致问题的完整错误和代码片段。这是我在特定模型视图中构建的一个方法,我在控制器中使用它将类型从字符串转换为日期时间-----------------“public datetime GetDateTime(){return convert.ToDateTi

在我使用entity framework 6的ASP.NET MVC 5项目中,我有一个日期和时间属性,其类型为“DateTime”,但在转换为DateTime语句时有一个FormatException。

要帮助您,我们需要更多信息。请分享您认为导致问题的完整错误和代码片段。这是我在特定模型视图中构建的一个方法,我在控制器中使用它将类型从字符串转换为日期时间-----------------“public datetime GetDateTime(){return convert.ToDateTime(string.Format({0}{1}),Date,Time))}“你可以从中得到一个解决方案。请检查此项添加“[DisplayFormat(DataFormatString=“{d MMM yyyy}”,ApplyFormatInEditMode=true]”后问题仍然存在。验证消息为“字符串未被识别为有效的日期时间”。请在代码片段中粘贴一些代码。适当的,否则对你有帮助。