I'm currently working on an MVC application and save some information into a database. From this information I save some checkbox values which is saved in its own column as
string 1, string 2, string 3
Now I'm trying to retrieve these values and make the checkbox checked in a different page. However where I should be getting two checkboxes I only get one. The returned values are correct but for some strange reason only one checkbox is displayed in the view
In my controller I have the following code
IEnumerable<MyEntity> myEntity = entityRepo.GetAll().Where(a => a.UserId == id);
List<CheckBox> checkBoxList = new List<CheckBox>();
foreach (var items in myEntity)
{
checkBoxList.Add(
new CheckBox
{
Text = items.EightWaste,
Checked = true,
Value = items.EightWaste,
});
}
Then in the view I've got
@foreach(var items in Model.EightWatseChkBox)
{
@Html.DisplayFor(model => items.Text)
@Html.CheckBoxFor(model => items.Checked)
}
And my UI output looks like
Can someone tell me where I'm going wrong please.