In my .cshtml file I have the following
@model MyProject.MyViewModel.Range
@for (int i = 0; i < Model.Range.Count; i++)
{
<div class="wrapper">
<div class="detail">
<p class="bold">@Model.Range.ElementAt(i).Key</p>
</div>
<div class="detail">
@Html.TextBoxFor(a => a.Range.ElementAt(i).Value)
</div>
</div>
}
So in the above I have a Dictionary<string, string>
. The key is already populated. I'd like the user to enter the value
The issue is when I click the save (submit) button, my controller's parameter Model.Range
always shows null
[HttpPost]
public ActionResult Edit(MyViewModel model)
{
//code. model.Range is always null
}
And my viewmodel is simply
public class MyViewModel
{
public Dictionary<string,string> Range{get;set;}
//default constructor is here
}