이 질문은 수 시간을 요구했지만 지금은 꽤 많은 시간을 낭비 했으므로 마침내 게시합니다. 그래서 요약하면 일부 복잡한 유형 특성 및 복합 유형 목록 특성을 갖는보기 모델이 있습니다.목록 속성이 컨트롤러의 게시물에 바인딩되지 않습니다.
public class ViewModel
{
public ViewModel()
{
Gains = new List<Gain>();
}
[UIHint("Common")]
public AllRegRecordsLog commonRegisterFields { get; set; }
public Potential Potential { get; set; }
[UIHint("Gains")]
public List<Gain> Gains { get; set; }
public void CreateGains(int count = 1)
{
for (int i = 0; i < count; i++)
{
Gains.Add(new Gain());
}
}
}
내가
@model Gains
table id="gainsTable" class="content-tables"style="width:98%">
<tr id="defaultGainsRow">
<td class="editor-label">
@Html.LabelFor(model => model.VolumeGainLow)
</td>
<td class="editor-field">
@Html.TextBoxFor(model => model.VolumeGainLow)
@Html.ValidationMessageFor(model => model.VolumeGainLow)
</td>
</tr>
<tr>
<td colspan="4">
<input id="addGainsButton"type="button" class="t-button" Value="Add Potential Gains"/>
</td>
</tr>
</table>
그러나 어떻게 든 나는 오류는 "얻을 내 특정보기 폴더 안에 편집기 템플릿을 배치 한
@Html.EditorFor(model => model.Gains)
내가으로이 속성을 호출 지금 내보기 createOrEdit, 사전에 전달 된 모델 항목의 형식은 'System.Collections.Generic.List이지만 예상대로입니다.'
asp.Net MVC 4
올바른 방향으로 알려주십시오.
감사
빌랄
감사를 사용 solvex. : ( – Bilal