@For i As Integer = 0 To Model.Count - 1
@Html.HiddenFor(Function(m) m(i).IdSonda)
Next
and the markup is:
Sonde.[6].IdSonda
instead of
Sonde[6].IdSonda
the strange thing is that if I send to the partial view the container model and the extract the list it work well.
EDIT:
@*doesn't work! *@
@Html.DisplayFor(Function(m) m, "_SondaViewList")
@*works !*@
@Html.DisplayForModel(Function(m) m)
@*works !*@
@For i As Integer = 0 To Model.Count - 1
@Html.DisplayFor(Function(m) m(i), "SondaView")
Next
@*doesn't work*@
@code
ViewData.TemplateInfo.HtmlFieldPrefix = "Sonde" + ViewData.TemplateInfo.HtmlFieldPrefix
End Code
@For i As Integer = 0 To Model.Count - 1
@<tr>
<td>@Html.TextBoxFor(Function(m) m(i).Id)</td>
<td>@Html.TextBoxFor(Function(m) m(i).Descrizione)</td>
</tr>
Next
@ModelType IList(Of MVCTest.SondaView)
@For i As Integer = 0 To Model.Count - 1
@<tr>
<td>@Html.TextBoxFor(Function(m) m(i).Id)</td>
<td>@Html.TextBoxFor(Function(m) m(i).Descrizione)</td>
</tr>
Next
vaizeman
Member
57 Points
78 Posts
binding list problem
Jul 04, 2012 04:10 PM|LINK
Hi,
i'm tring to bind a list in a asp.net mvc 3.0 form but I have the "well known" extra period in the name of collection.
es this is the main model:
Public Class ContainerModelView Public Property Sonde As IList(Of AssignableSondaView) = New List(Of AssignableSondaView) End Classin the page i call a partial with the collection:
<div id="grid_sonde"> @Html.Partial("_SondeGrid", Model.Sonde) </div>then in the partial I try to bind:
and the markup is:
Sonde.[6].IdSonda
instead of
Sonde[6].IdSonda
the strange thing is that if I send to the partial view the container model and the extract the list it work well.
EDIT:
@*doesn't work! *@ @Html.DisplayFor(Function(m) m, "_SondaViewList") @*works !*@ @Html.DisplayForModel(Function(m) m) @*works !*@ @For i As Integer = 0 To Model.Count - 1 @Html.DisplayFor(Function(m) m(i), "SondaView") Next @*doesn't work*@ @code ViewData.TemplateInfo.HtmlFieldPrefix = "Sonde" + ViewData.TemplateInfo.HtmlFieldPrefix End Code @For i As Integer = 0 To Model.Count - 1 @<tr> <td>@Html.TextBoxFor(Function(m) m(i).Id)</td> <td>@Html.TextBoxFor(Function(m) m(i).Descrizione)</td> </tr> Next@ModelType IList(Of MVCTest.SondaView) @For i As Integer = 0 To Model.Count - 1 @<tr> <td>@Html.TextBoxFor(Function(m) m(i).Id)</td> <td>@Html.TextBoxFor(Function(m) m(i).Descrizione)</td> </tr> NextSondaView:
@ModelType MVCTest.SondaView @code ViewData.TemplateInfo.HtmlFieldPrefix = "Sonde" + ViewData.TemplateInfo.HtmlFieldPrefix End Code <tr> <td>@Html.TextBoxFor(Function(m) m.Id)</td> <td>@Html.TextBoxFor(Function(m) m.Descrizione)</td> </tr>somebody can explain this?