My form keys are:
Request.Form.AllKeys
{string[9]}
[0]: "__RequestVerificationToken"
[1]: "stud.LastName[0]"
[2]: "stud.FirstName[0]"
[3]: "stud.Number[0]"
[4]: "stud.LastName[1]"
[5]: "stud.FirstName[1]"
[6]: "stud.Number[1]"
They all have values.
My action looks like this:
[ValidateAntiForgeryToken]
[HttpPost]
public ActionResult Add(Student[] stud)
Student class has properties :FirstName, LastName, Number.
The problem is that stud is null?
Isn’t a way to get it populated with submitted data, o or have to take the data from Request.Form
You should have this kind of values (note the changed [] location)
Something wrong is going on in your views – generated inputs(and when submitted, form values) do not have ‘[]’ in right places in thier names. Take a look at this article by Phil Haack about model binding to a list.