How to make Check Box List in ASP.Net MVC

后端 未结 2 1135
孤城傲影
孤城傲影 2020-11-28 04:01

I have a form with a list of checkboxes. A user can select all values, no values, or any in between. Example:

\"

2条回答
  •  死守一世寂寞
    2020-11-28 04:36

    You can also do Using jquery.No need to change any controller or action.It will simply add the selected checkboxes value in the database table's column as a coma separated.Just add the code in the View Page.

     
    @Html.HiddenFor(model => model.hobbies, new { htmlAttributes = new { id = "hobbies" } }) Hobbies : Reading Writing @Html.ValidationMessageFor(model => model.hobbies)

提交回复
热议问题