Is there any sample code of how to read th开发者_运维问答e id of the selected checkbox in a view from a controller.
<% foreach (var item in Model.projects) { %>
<tr><td><input type="checkbox" name="selectedObjects" value=" <%=item.ID %>">
<%=item.Name %>
<% } %>
What must be the code on the controller to get the ID of the selected checkboxes?
Add a parameter named "selectedObjects" to your action method, and it will be populated by the selected values.
public ActionResult myPostAction(int[] selectedObjects)
{
foreach (var value in selectedObjects)
{
}
}
精彩评论