when student select multiple hobbies then I want to insert them in table
database fieldname
studenthobbies bit
student.cs
- public Nullable<bool> studenthobbies { get; set; }
HomeController.cs
- [HttpPost]
- public ActionResult Create(student student, List
hobbies) - {
- //foreach (student hobby in hobbies)
- //{
- // student updatedHobby = InsAjaxEntities.students.ToList().Find(p => p.studenthobbies == hobby.studenthobbies);
- //}
- en.students.Add(student);
- en.SaveChanges();
- return RedirectToAction("Index");
- }
Create.cshtml
- class="row">class="form-group col-lg-10">
- ="control-label col-lg-2">StudentHobby:
- "checkbox" id="wallyball" name="wallyball" value="wallyball" /> wallyball
- "checkbox" id="swimming" name="swimming" value="swimming" checked /> swimming
- "checkbox" id="News" name="News" value="News" /> News
- type="button" value="submit" class="btn-primary">Save
- @section scripts {
I am using the ajax code for insert the data how to insert multiple hobby in table?
I want to insert multiple hobby in table?
help?
Jignesh KumarPosted Jun 21, 2020, 10:55 PM
rahul patilPosted Jun 22, 2020, 1:17 PM
hello jignesh