This project is read-only.
2
Vote

How do you get the value of an embedded DropDownListFor

description

I have an dynamically set embedded DropDownListFor in a column for each row. The end user then selects a value in each DropDownListFor. On the Submit button I can't find a viable solution to obtain the values selected in the DropDownListFor per each row.

VIEW

Html.Grid(Model.List).Columns(columns =>
{
  columns.Add(c => c.ListofBlah)
                       .Encoded(false)
                       .Sanitized(false)
                       .RenderValueAs(o => Html.DropDownListFor(c => c.selectedBlah,
                                                                                                         new SelectList(c.ListofBlah, "blahValue",                "blahText", selectedBlahValue)
})
<p> <input type="submit" value="Save" name="action:Save" </p> CONTROLLER

public ActionResult Save(FormCollection formCollection)
{
   __Here is where I need help... I've thought of adding a checkbox and setting a unique ID concatenating the fields I need to get data from, but that feels wonky.. __
}

Thanks for your help in advance.

comments