Hello Everyone,
Hope everyone is fine !
I have bind Contact in CheckBoxList successfully.
But i am not ableto save the checked item to database.Everyone while saving , it shows the List as Null.
Following is my View Code :
- @foreach (var item in ViewBag.ContactsCheckbox)
- {
- <div class="custom-control custom-checkbox">
- <input id="chk@(item.Id)" class="custom-control-input" type="checkbox" value="@item.Id" checked="@item.IsChecked" />
- <label class="custom-control-label" for="chk@(item.Id)">@item.ContactName </label>
- </div>
- }
Following is Controller Code :
- public ActionResult Add(MemoriesImagesMaster mi, List<ContactsMaster> items)
- {
- Do_Validation val = new Do_Validation();
- List<MemoriesImagesMaster> list = new List<MemoriesImagesMaster>();
- Guid LoginId = new Guid(Session["UserId"].ToString());
- foreach (ContactsMaster item in items)
- {
- if (item.IsChecked)
- {
- ViewBag.Message += string.Format("{0}\\n", item.ContactName);
- }
- }
- }
On View, the data is bind using Memory Model and on same the list is getting bound using the Contact Model
Thank you in advance.