MVC Form not able to post List of objects

后端 未结 2 987
暗喜
暗喜 2020-11-22 11:48

so I have an MVC Asp.net app that is having issues. Essentially, I have a View that contains a form, and its contents are bound to a list of objects. Within this loop, it lo

2条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 12:18

    Please read this: http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx
    You should set indicies for your html elements "name" attributes like planCompareViewModel[0].PlanId, planCompareViewModel[1].PlanId to make binder able to parse them into IEnumerable.
    Instead of @foreach (var planVM in Model) use for loop and render names with indexes.

提交回复
热议问题