mercredi 24 janvier 2018

MVC Core how to use checkboxes to retrieve the foreach ID

sorry if my title is very unclear.

So I have this following code:

                @{
                    foreach (var m in Model.AsEnumerable())
                    {
                        <tr class="oddeventable">

                            <td>
                            <Student Name>
                            </td>
                            <td>
                                @Html.ActionLink("Delete", "DeleteStudent", new { stud = m.Id }, new {@class="btn btn-danger" })
                            </td>
                        </tr>

                        i++;
                    }
                }

              <input type="submit"/>

How do I change the @Html.ActionLink("Delete", "DeleteStudent", new { stud = m.Id }, new {@class="btn btn-danger" }) Into a checkboxe so when the foreach is being run, there will be many rows with the checkbox and the user can select each rows then click "Submit", when submit to the controller, I want to retrieve the M.id so I can do the appropriate action.

Thanks a lot.




Aucun commentaire:

Enregistrer un commentaire