I am writing a MVC .net application which has an employee and its designation. Designation is populated in a drop down list. Not sure why am I getting the model state as always false and hence the employee is not able to be saved.
Code that is used to populate the designation drop down is as below.
Any help will be highly appreciated!!
- public void PopulateDesignations()
{
//List myDesig = new List();
IEnumerable myDesig = ObjDB.Designations.Select(i => new SelectListItem { Text = i.DesignationName,Value= i.DesignationID.ToString() });
//myDesig = ObjDB.Designations.ToList();
ViewBag.Designations = myDesig;
}
Controller method here which is called when Create employee method is called via POST
Create employee view file code here
Tried to troubleshoot but failed
avinash goyal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.