In my code i need to loop through hidden courses in jquery then remove it from employee course table in database sql in edit httppost under save button
see green font in place of my code i need
- [HttpPost]
- public ActionResult Edit(Cusomemp2 custom)
- {
- var result = db.Employees
- .Where(p => p.Id == custom.Id)
- .Include(c => c.EmployeeCourses)
- .FirstOrDefault();
- if (custom.empcourses.Any())
- {
- //here i need to loop through data and remove hidden courses
- }
- result.Name = custom.Name;
- result.EmployeeCourses = custom.empcourses;
- db.SaveChanges();
- return View();
- }
i use following model Cusomemp2 to represent data
- public class Cusomemp2
- {
- public int Id { get; set; }
- public List
empcourses { get; set; } - }
in edit view model my code as following
- @model StudentCourses.Models.Cusomemp2
- @{
- Layout = null;
- }
- "viewport" content="width=device-width" />
-
Edit -
- @using (Html.BeginForm())
- {
- "hidden" value="@ViewBag.hid" id="hid" />
- Name: @Html.TextBoxFor(a => a.Name)
- Courses:@Html.DropDownList("CourseId")
"tb">
- "submit" value="save" />
- }
ahmed salahPosted Sep 27, 2016, 5:36 PM
Pradeep ShetPosted Sep 27, 2016, 2:07 PM