Dynamic list of checkboxes and model binding

前端 未结 2 2105
广开言路
广开言路 2020-12-14 21:13

I\'m trying to create a view that contains a list of checkboxes that is dynamically created from a database, and then retrieve the list of selected ones when the form is pos

2条回答
  •  甜味超标
    2020-12-14 21:44

    Have you seen: http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx?

    We basically wrote our own control to render the HTML like

    
    

    Model Looks Ok, we wrote a custom helper, so our aspx pages look like:

    <%= Html.DropDownFor(m=>m.products) %>
    

    If you follow phil haacks post, your model should automatically bind in your controller.

提交回复
热议问题