I want to post a form data which has grid kind of layout and a column in each row contains dropdownlist. selected value in the dropdown list maps to item id of that row.
I want to know what are the different ways to post this data to controller action in this case?
Passing as individual parameters is already ignored option as my form will have dynamic data and it may have n number of records. Am I correct in this thinking?
Thought of FormCollection, is this right choice?
As always I would start by defining a view model:
then have a GET controller action which will populate a collection of this view model and in the corresponding view I would use editor templates:
and in the corresponding editor template (
~/Views/Shared/EditorTemplates/MyViewModel.cshtml):and finally this will post the selected values: