READ ALSO
Introduction
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
- First step to prepare classes for employee and department
- Second step to create a context for both class
- third step to prepare a controller for department, as well as prepare view for department
- forth step to prepare controller for employee, as well as prepare view for employee.
Error
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.
SnapShot
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
Read other related articles
ASP.NET
Also read other articles