lundi 2 novembre 2015

retrieve id's from selected checkboxes

I have some checkboxes and I want to retrieve in idList the list of id's coresponding to the selected checkboxes.

This is my code:

@foreach (var inv in Model.Invoices)
{
    <tr>
        <td>@Html.CheckBox("Selected", true, new { @class = "SelectInvoice", data_id = inv.ID, id = "Selected-" + inv.ID })</td>

For now I get all the id's from the model:

  @using (Html.BeginForm("SendUnpaid", "Invoice"))
        {
            @Html.Hidden("idList", string.Join(",", Model.Invoices.Select(row => row.ID)))

How can I do that? Thank you!




Aucun commentaire:

Enregistrer un commentaire