I am struggling with what I think should be pretty simple. I have a razor page, which has a list of choices with selection checkboxes. I wanted the user to be able to check as many checkboxes as he liked. I have to code to get the list of choices going, but can't seem to add the button in any way that actually returns the selections to my controller. Can someone help?
<form method="post">
<div class="form-group">
<div>
<table>
<tr>
<th>Name</th>
<th>Selected</th>
</tr>
@foreach (var item in @Model.Choices)
{
<tr>
<td> @Html.DisplayFor(modelItem => item.Text) </td>
<td> @Html.CheckBoxFor(modelItem => item.Selected) </td>
</tr>
}
</table>
</div>
I need some code at the end that adds a button to the form and binds/returns the Choices (including the Selected).