我尝试在MVC中创建一个新的Employee。 控制器:MVC - 在Northwind DB中创建控制器操作CreateNewEmployee
HireEmployeeBL.EmployeeBL employeeBl = new HireEmployeeBL.EmployeeBL();
public ActionResult HireNew(int id)
{
return View();
}
[HttpPost]
public ActionResult HireNew(int id, Employee employee)
{
employee.ReportsTo = new Manager { EmployeeID = id };
employeeBl.AddEmployee(employee);
return RedirectToAction("Subordinates");
//return View();
}
服务器错误:
The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult HireNew(Int32)' in 'MvcEmployee.Controllers.EmployeeController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters
你路过这两个类型'int'的ID和类型Employee'的'员工到控制器的动作? – 2013-04-10 18:12:55
我编辑了你的标题。请参阅:“[应该在其标题中包含”标签“](http://meta.stackexchange.com/questions/19190/)”,其中的共识是“不,他们不应该”。 – 2013-04-10 18:26:40
是的,即时通过他们两人控制器行动 – 2013-04-10 18:38:35