fix parameters dictionary contains a null entry

April 10, 2015 0 Comments


Basically that's type of error occurs due to null value. But i have already try to pass some value, manually in the controller function. Always i get this error. Ok let's start to story of the error. I want to get the record from single department table and that's name is hyperlinked. Now, When i click to any hyperlink then open respective employee details, which is stored in another table. What i was done. First i was write the code for retrieving the value from single data base table, on that time, my code run successfully. But in Next time when i wrote the code for retrieving the record from two database table, on that time, i got the error.

What steps i have taken

  1. First step to prepare classes for employee and department
  2. Second step to create a context for both class
  3. third step to prepare a controller for department, as well as prepare view for department
  4. forth step to prepare controller for employee, as well as prepare view for employee.


The parameters dictionary contains a null entry for parameter 'deptid' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult linkEmp(Int32)' in 'WebApplication10.Controllers.EmployeeController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters.


How to fix it

Prepare the seperate Context class for each model. I have two class that is employee and department , If you want to retrieve data from both class then you want to make two seperate context for each. I have two context that is 1. EmployeeContext 2. DepartmentContext

Jacob Lefore

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google