TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Anisha Kumaradas
NA
46
10.8k
Saving Selected Checkbox in database using MVC
Feb 9 2018 5:26 AM
Requirement:To save selected checkbox values in a table in database.
Model:
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.
Reply
Answers (
1
)
Message Preview with Number
return value in post method using async Task(C# And Mongodb)