On my .cshtml file, I have this form with checkboxes:
<div class="checkbox">
<label>
<input type="checkbox" value="Clothing" name="Child1GiftTypeNeed" checked>
Clothing
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" value="Shoes" name="Child1GiftTypeNeed">
Shoes
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" value="Coat/Jacket" name="Child1GiftTypeNeed">
Coat/Jacket
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" value="Books" name="Child1GiftTypeNeed">
Books
</label>
</div>
How do I insert the value of these checkboxes in one single database column separated by commas?
(I am a brand new C# learner)
This is my insert from codebehind:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Index([Bind(Include = "Id,Child1GiftTypeNeed")] HGProgram hgProgram)
{
if (ModelState.IsValid)
{
//Save to my database
db.HGPrograms.Add(hgProgram);
db.SaveChanges();
}
}
Aucun commentaire:
Enregistrer un commentaire