EditorFor collection of items in my model

让人想犯罪 __ 提交于 2019-11-29 23:05:27
  1. Correct - you need your own template (See http://jarrettmeyer.com/post/2995732471/nested-collection-models-in-asp-net-mvc-3)
  2. Yes this can work - the model binder will populate properly if they are named the right thing id[0], etc. see Phil Haack's article on this: http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx

Edit for #2 - I read your original post a little incorrectly. If you put them all into a single textbox, then you will need to parse them (or create your own model binder). You could have an editor that adds new textboxes to the DOM for each item and then model binder will correctly repopulate the list. However in the case you mentioned, your options are manually do this on the server, or use your own model binder (which would be fairly easy here) to break them apart into a model. Either or : )

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!