C# ASP.Net日期字段值在每次编辑时重置
在我的ASP.Net项目中,我的模型具有以下属性:C# ASP.Net日期字段值在每次编辑时重置,c#,asp.net,C#,Asp.net,在我的ASP.Net项目中,我的模型具有以下属性: [DataType(DataType.Date)] public Nullable<System.DateTime> dt_ent { get; set; } 控制器: public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusC
[DataType(DataType.Date)]
public Nullable<System.DateTime> dt_ent { get; set; }
控制器:
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Process process = db.Process.Find(id);
if (process == null)
{
return HttpNotFound();
}
return View(process);
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "id,dt_ent")] Process process)
{
if (ModelState.IsValid)
{
db.Entry(process).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
}
在此处编写html代码。视图是使用标准EF操作创建的。编辑日期字段后,在视图/控制器交互方面会发生什么?您可以发布处理此编辑的操作吗?已添加控制器。
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Process process = db.Process.Find(id);
if (process == null)
{
return HttpNotFound();
}
return View(process);
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "id,dt_ent")] Process process)
{
if (ModelState.IsValid)
{
db.Entry(process).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
}