@Html.HiddenFor does not work on Lists in ASP.NET MVC

后端 未结 13 910
灰色年华
灰色年华 2020-11-27 15:13

I\'m using a model that contains a List as a property. I\'m populating this list with items i grab from SQL Server. I want the List to be hidden in the view and passed to th

13条回答
  •  一整个雨季
    2020-11-27 15:37

    Html.HiddenFor is designed for only one value. You will need to serialize your list in some way before creating the hidden field.

    For example, if your list is of type string, you could join the list into a comma separated list, then split the list after post back in your controller.

提交回复
热议问题