Problem with MVC EditorFor named template

后端 未结 3 2152
滥情空心
滥情空心 2020-12-25 13:42

I have what appears (to me anyway) to be a strange problem...

I created a simple editor template for a SelectListItem (SelectListItem.cshtml in the ~/Views/Shared/Ed

3条回答
  •  借酒劲吻你
    2020-12-25 14:11

    If you're using EditorFor, I don't think the looping solution will work. It seems that using the IEnumerable template is the only way for the form inputs to be named correctly; if you just call EditorFor repeatedly, then your form s will have the same ID, rather than indexed IDs.

    I experienced this issue and the solution was to emit the enumerable template and not loop through the list items.

    Sorry to make this an answer not a comment -- don't have commenting rights.

提交回复
热议问题