Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
Error:
C#
The model of type 'BusinessClassLibrary.Employee' could not be updated.

I am new to asp.net mvc. I got the above error. When i use UpdateModel(employee) method this error comming.

Employee.cs
C#
public int ID { get; set; }
       [Required]
        public string Name { get; set; }
        public string Gender { get; set; }
        public string City { get; set; }
        public string DOB { get; set; }


In database DOB datatype is DateTime, but in .cs class i taken as a string.Is it creates any prob?
EmployeeController.cs
C#
[HttpPost]
        [ActionName("create")]
        public ActionResult Create_Post()
        {
            if (ModelState.IsValid)
            {
                Employee employee = new Employee();
                UpdateModel(employee);

                EmployeeBusinessLayer employeebusinesslayer = new EmployeeBusinessLayer();
                employeebusinesslayer.AddEmployees(employee);
                return RedirectToAction("Index");
            }
            return View();
        }


Why that error comming? Where i did a mistake. Plz help to me.

Thanking you
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900