---
title: "cannot save changes of courses if remove in edit httppost"  
description: "cannot save changes of courses if remove in edit httppost"  
author: "Abeer Shlby"  
published: 2016-09-10  
updated: 2016-09-10  
canonical: https://www.mindstick.com/forum/34175/cannot-save-changes-of-courses-if-remove-in-edit-httppost  
category: "asp.net mvc"  
tags: ["asp.net mvc", "linq to sql", "linq to entities"]  
reading_time: 1 minute  

---

# cannot save changes of courses if remove in edit httppost

[Problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic)

when [remove](https://yourviews.mindstick.com/story/4554/8-harmful-weeds-to-remove-from-garden) course then click submit not save changes although

it removed from [client side](https://www.mindstick.com/forum/160418/what-are-the-best-practices-for-securely-storing-bearer-tokens-on-the-client-side) by jquery

## Details

in edit view for every [employee](https://www.mindstick.com/articles/85431/remote-employee-training-tips-tricks) i need to do changes by remove or add new [courses](https://www.mindstick.com/articles/12720/searching-for-the-best-courses-in-mba-read-on) for employee

if i add new courses then click [submit button](https://www.mindstick.com/forum/12834/make-text-appear-when-submit-button-clicked-and-checkbox-is-unchecked) it save what i do but if i remove course from courses then click submit it will not save courses i removed so that i need to check what is wrong in my code my code working without any problem but only have problem i [cannot save](https://www.mindstick.com/forum/33720/cannot-save-data-in-database) courses removed in [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) in employeecourse table when click submit employeecourse table have Id,EmployeeId,CourseId jquery remove client side attached with my [question](https://www.mindstick.com/blog/23175/how-to-solve-neet-question-paper-in-less-time) image [describe](https://www.mindstick.com/interview/12752/what-is-ddms-describe-some-of-its-capabilities) what i need as following

\
![cannot save changes of courses if remove in edit httppost](https://www.mindstick.com/mindstickforums/c4d556f0-26a0-4ede-840e-586a1e876cec/images/c119a386-fce2-4c22-852d-dce823a89aae.png) link to my code to all project as following\
http://www.mediafire.com/download/3xs35gecmvkksj1/all_project.txt\
code \
**my code as following**

```
[HttpPost]          public ActionResult Edit(EditEmployeeVm model)          {              var emp = db.Employees.FirstOrDefault(f => f.Id == model.Id);              foreach (var couseid in model.CourseIds)              {                  db.EmployeeCourses.Add(new EmployeeCourse { CourseId = couseid, EmployeeId = emp.Id });                  db.SaveChanges();              }                      return View();  my(custom model) view model using for that   public class EditEmployeeVm      {          public int Id { set; get; }          public List<SelectListItem> Courses { get; set; }          public int[] CourseIds { set; get; }          public List<CourseVm> ExistingCourses { set; get; }      }      public class CourseVm      {          public int Id { set; get; }          public string Name { set; get; }      }  }  
```

\


---

Original Source: https://www.mindstick.com/forum/34175/cannot-save-changes-of-courses-if-remove-in-edit-httppost

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
