I have really strange problem. So, my structure is like this
<div id="tasks">
@Html.Partial("_Tasks", tasks)
</div>
and in _Tasks I do a foreach through all tasks and for each task I have additional partial
...
@Html.Partial("_Time", new TimeViewModel(task))
...
and inside of _Time I have form
...
@Html.TextBoxFor(m => m.Name)
....
So in a view I render a partial and then inside again multiple partials and inside it a form. When I perform a page load, it works. Problem begins with when I'm using ajax, so I perform edit to Time and post to server and update #tasks with returned html.
I'm my controller action I have...
...
return View("_Tasks", tasks);
and the problem now is that all inputs generated by @Html.TextBoxFor(m => m.Name) have the same value. Why? If I do
@Html.DisplayFor(m => m.Name)
I works just fine. I also tried with
@Html.TextBoxFor(m => m.Name, new { Value = Model.Name })
and it works, but it looks hackish to me.
The question is, why is get this behavior? Why does all TextBoxFor have same value?