0

I have a Model class

class ItemModel
{
    public List<string> Values { get; set; }
}

And a view

@model List<ItemModel>

@using (Html.BeginForm(null, null, FormMethod.Post))
{
    @Html.ValidationSummary()
    for (var i = 0; i < Model.Count; i++)
    {
            @Html.DropDownListFor(m => m[i].Values, new SelectList(Model[i].Values))
    }
    <input type="submit" value="Save"/>
    }
}

How should the view look like, if I want to get the list values back in model after submitting the form. The values will be edited with js on client side. The selected item is insignificant.

lng
  • 805
  • 1
  • 11
  • 31
  • use editor templates http://stackoverflow.com/questions/13483715/in-mvc4-how-to-save-multiple-row-edits-at-once/13484000#13484000 – Shyju Dec 05 '13 at 22:00
  • I suppose you mean that I use the EditorFor instead of iterating over model list. But what about getting values from the html select into the string list. I don't think it helps. – lng Dec 05 '13 at 23:17
  • But thanks for the EditorFor. I will use it. Maybe i will see it then. – lng Dec 05 '13 at 23:24

0 Answers0