Within my view I need multiple input boxes for a dynamic number of values. For example, if I have a dynamic amount of input boxes (shown here http://jsfiddle.net/skip405/9sX6X/6
The process of converting data from request to the action input parameters in the controller is called Model Binding. A lot of flexibility is implemented here, see Model Binding To A List
The basic idea is that if you have several inputs with the same name, they can be bound to a List<string>
.
more complex scenarios are possible as well: if you have a like
public class Person
{
public int Age{get; set;}
public string Name{get; set;}
}
and an action method:
public ActionResult DoSomething(List<Person> people)
{
//do something
}
the input fields can be like this:
<input type="number" name="[0].Age" />
<input type="number" name="[0].Name" />
<input type="number" name="[1].Age" />
<input type="number" name="[1].Name" />