I have a string dictionary in my model and I would like its key value pairs to show up in the view and then in my POST values. Tried to do it by this thread and the suggested blog post without luck.
The items of the dictionary are shown in the view but there's always null in the post data. Shall I add some attributes to the model class properties?
Some details of my solution:
Model:
public class WorkPlaceModel {
public Dictionary<string, string> WorkplaceData = null;
}
View third version, none of them worked:
foreach (var kvp in Model.WorkplaceData)
{
@Html.Label(kvp.Key);
@Html.TextBoxFor(m => m.WorkplaceData[kvp.Key]);
}