Pass array of models from view to controller

Posted by niaher on Stack Overflow See other posts from Stack Overflow or by niaher
Published on 2010-04-23T10:32:48Z Indexed on 2010/04/23 20:23 UTC
Read the original article Hit count: 167

Filed under:

Is it possible to pass array of models from view to controller? How?

Suppose my model is

public class Car
{
    public string Name
    {
        get;
        set;
    }
    public int Price
    {
        get;
        set;
    }
}

And I have a <form> where user can dynamically add new cars. When he submits, I want to catch it in the action method

public ActionResult CreateCars(Car[] cars)

Is it possible?

© Stack Overflow or respective owner

Related posts about asp.net-mvc-2