I have a very large form that represents a month or more of data. Each day has 3 drop-downs the user can update and then i need to save the data in the form. I should mention I had to make a custom dropdown (HERE) to use a style class so it’s not the standard Html.dropdown()
So what I’d like to do is something like…
View:
@{
List<string> DropdownValues = new List<string>();
}
@using(Html.BeginForm("Method","Controller",FormMethod.Post,new{ Data = DropdownValues}))
{
@Html.CustomDropdown("Name1",ListOfOptions1)
@Html.CustomDropdown("Name2",ListOfOptions2)
@Html.CustomDropdown("Name3",ListOfOptions3)
<input type="submit" value="Submit" />
@{
//Do on submit
DropdownValues.add(Name1.value);
DropdownValues.add(Name2.value);
DropdownValues.add(Name3.value);
}
}
Ideas?
Thanks!
You can access form element direct from controller code without them having to be part of the Action parameters. Maybe this is what you are looking for?…
You could even put it in a loop depending on what you are doing with the data…