【发布时间】:2017-09-15 05:18:53
【问题描述】:
我是 asp.net MVC 5 的新手。 我的数据库中有一个类型为 DateTime 的列,我想使用 datepicker 将日期插入其中。但是,它给了我一个错误。 the error
我的模型是这样的
[Display(Name = "Found Date")]
public System.DateTime foundDate { get; set; }
我的看法是
<div class="form-group">
@Html.LabelFor(model => model.foundDate, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.foundDate, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.foundDate, "", new { @class = "text-danger" })
</div>
</div>
脚本
$(document).ready(function ()
{
$("#foundDate").datepicker( {dateformat: 'dd/MM/yyyy'} );
});
应该将哪种日期格式传递给数据库中的日期时间?如何更改它以匹配日期选择器的返回类型?
任何解决此问题的帮助将不胜感激。
【问题讨论】:
标签: c# asp.net-mvc datepicker razorengine