Hi,
I have the following EditorFor template:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<List<ContactDto>>" %>
<%@ Import Namespace="c2.bases.dto.structure"%>
<%
for (var i = 0; i < ViewData.Model.Count; i++)
{%>
<%=Html.EditorFor(x => x[i])%>
<%}
%>
The problem is that it is not generating the correct name attribute, it generates the following name attribute for one of the elements:
name="TrainingLookUpContainer.Contacts.[0].Surname"
You can see that there is an extra '.' character after the last Contacts and before the indexer [0].
It should be
name="TrainingLookUpContainer.Contacts[0].Surname"
The object is not getting bound because of this extra '.'.
This editor for is being called from another page like this:
<div style="background: #fff;height:100%">
<%= Html.EditorFor(x => x.TrainingLookUpContainer.Contacts, "TrainingCategory")%>
</div>
I found this article that seems to suggest I am doing it right link text.
I thought it might be the lamda but I think it might be a bug due to the nesting.
I have a work around where I pass in the Containing object TrainingLookUpContainer and everything is good.
Can anyone suggest a better way of just binding to the List?
Cheers
Paul