开发者

Pass a collection of Items from the view to the controller. MVC 3

开发者 https://www.devze.com 2023-03-08 13:56 出处:网络
I\'m trying to edit a model that contains a collection of another model as member. I\'d like to create a table simulating a grid for editing this collection of items. Then, when submitting the form I

I'm trying to edit a model that contains a collection of another model as member. I'd like to create a table simulating a grid for editing this collection of items. Then, when submitting the form I want to pass the following parameters to the controller.

public ActionResult SavePerformanceGraphItem(int itemId, ICollection<PerformanceGraphItem> items)
{

}

How should I name the inputs in the view 开发者_如何学运维in order to be retrieved by the controller as I'd like?


the names of the input fields would be something like:

name="items[0].PropertyOne"
name="items[0].PropertyTwo"
...
name="items[1].PropertyOne"
name="items[1].PropertyTwo"
...
name="items[2].PropertyOne"
name="items[2].PropertyTwo"

etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消