I have a strongly typed view with a list of user objects in the model.
In the view, I display text fields for each object in the list:
@using (Html.BeginForm("SaveData", "Localization", FormMethod.Post))
{
foreach (YB.LocalizationGlobalText m in Model.GlobalTexts)
{
@Html.Label(m.LocalizationGlobal.Name)
@Html.TextBoxFor(model => m.Text)
<br />
}
<input type="submit" value="Save" />
}
Now, how to get updated data from text fields in my model. I can see the updated data in the video colored:
[HttpPost]
public virtual ActionResult SaveData(FormCollection form)
{
return View();
}
form ["m.Text"] = "testnewdata1, testnewdata"
But how do I get this mapping to a model, so I have updated values for each object. Or how can I get this purely from a formcollection, something like this .. form [someid] ["m.Text"]
Edit:
I also tried passing the model as a parameter, but the model data is empty.
[HttpPost]
public virtual ActionResult SaveData(LocalizationModel model, FormCollection form)
{
return View();
}
When I look in the model: model.GlobalTexts = null