c# - ASP.NET MVC BeginCollectionItem issue -
i having issue html helper begincollectionitem. seems binding item view , changes not being propagated.
i have partial view , model bound ienumerable. below snippet.
<tbody> @foreach (var entry in model) { <tr> @using (html.begincollectionitem("editedentries")) { <td>@entry.storeid</td> <td>@entry.district</td> <td>@html.editorfor(x => entry.adjhrs)</td> } </tr> } </tbody> if remove the foreach works, need use foreach because collection returned partial view ajax call along table , members.
the begincollectionitem designed work partial view. create 1 model (i'll assume named mymodel , name partial "_mymodel.cshtml")
@model mymodel <tr> @using (html.begincollectionitem("editedentries")) { <td>@html.displayfor(m => m.storeid)</td> <td>@html.displayfor(m => m.district)</td> <td>@html.editorfor(m => m.adjhrs)</td> } </tr> and in other partial, replace foreach loop with
<tbody> @foreach (var entry in model) { @html.partial("_mymodel", entry) } </tbody>
Comments
Post a Comment