0
我有一个由Visual Studios为我生成的名为EditEmployee.shtml的视图。在其中,有一行创建文本框以允许修改员工记录。在Html.EditorFor()中显示当前值
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
这里的控制器:
public ActionResult EditEmployee(int id = 0)
{
using (MVCTrainingDB db = new MVCTrainingDB())
{
var emp = db.Employees.Find(id);
if (emp == null)
{
return RedirectToAction("Index", "Home");
}
else
{
return View();
}
}
}
这完美的作品,但它并没有显示什么当前值是模型,而不是它只是一片空白。我怎样才能修改这个设置文本框的值为model.Name?
你要为你的操作方法的名称属性值? – Shyju
@shyju我添加了控制器的代码 – DForck42