1

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?

1

1 Answer 1

1

I don't think so.

I believe you'd have to build the form as you went and catch the formcollection.

public ActionResult CreateCars(FormCollection formCollection)

And then go through all the elements of the formCollection.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.