Uvie Jakpor

Uvie Jakpor

  • NA
  • 15
  • 834

how to save and update a record using the same view

Dec 16 2014 1:41 AM
hello guys,am working on an online admission system where i store records of students in my database.
i have a form where i want to implement a save and update record in the same view insteasd of passing the values to another view for update..here is my code below




 if (ModelState.IsValid)
            {
                student = db.Students.Find(student.ID);
                if (student == null)
                {

                    db.Students.Add(student);
                }
                else
                {

                    db.Entry(student).State = EntityState.Modified;
                  
                }
                db.SaveChanges();