MVC : The parameters dictionary contains a null entry for parameter 'k' of non-nullable type 'System.Int32'

后端 未结 5 800
情书的邮戳
情书的邮戳 2020-12-05 17:08

I am new to MVC. In My Application , I\'m Retrieving the Data from Mydatabase. but when I run my Application it show Error Like This this is my url

<         


        
5条回答
  •  北海茫月
    2020-12-05 17:45

    It seems that your action needs k but ModelBinder can not find it (from form, or request or view data or ..) Change your action to this:

    public ActionResult DetailsData(int? k)
        {
    
            EmployeeContext Ec = new EmployeeContext();
            if (k != null)
            {
               Employee emp = Ec.Employees.Single(X => X.EmpId == k.Value);
    
               return View(emp);
            }
            return View();
        }
    

提交回复
热议问题