Requirement:To save selected checkbox values in a table in database.
public class Profiletemplate
{
public int RoleID { get; set; }
public string FieldName { get; set; }
public string BlockName { get; set; }
public int FieldID { get; set; }
}
Controller:
if (ModelState.IsValid)
{
objent.sp_addProfileTemplate(pro.RoleID, pro.BlockName, pro.DisplayOrderBlock, pro.DisplayOrderField, pro.FieldID, pro.ValueType, pro.Maxlength, pro.IsRequired, pro.FieldColumnNumber, Convert.ToInt32(Session["ID"].ToString()));
return RedirectToAction("ProfileTemplate", "Admin");
}
View:
@foreach (var cat in Model.lstfields)
{
<label class="container">
@cat.FieldName
<input type="checkbox" id="@cat.FieldID" value="@cat.FieldName" class="chkclass" />
<span class="checkmark"></span>
</label>
}
I couldnot pass FieldID to my controller to save it in my database.
Please help me to resolve this issue
Thanks in Advance.
Regards,
Anisha.