嗨我想提交父母和子女,我可以提交父母罰款,但不是孩子,有沒有辦法做到這一點?提交父母和子女在剃刀
這是我的代碼。
@model IECWeb.Models.CurrencyDay
using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>CurrencyDay</legend>
<div class="editor-label">
@Html.LabelFor(model => model.CurrencyDate)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.CurrencyDate)
@Html.ValidationMessageFor(model => model.CurrencyDate)
</div>
<p />
<table>
<tr>
<th>Currency</th>
<th>Rate</th>
</tr>
@foreach (var item in Model.Currency) {
<tr>
<td>
<div class="editor-field">
@Html.EditorFor(model => item.Name)
@Html.ValidationMessageFor(model => item.Name)
</div>
</td>
<td>
<div class="editor-field">
@Html.EditorFor(model => item.Rate)
@Html.ValidationMessageFor(model => item.Rate)
</div>
</td>
</tr>
}
</table>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
當我提交我得到CurrencyDay對象,但不是貨幣
感謝 sushiBite名單。
謝謝,這工作得更好,我不需要將ICollection轉換爲列表,看起來更清潔:D我看到這個後需要重寫一些代碼:D再次感謝 – sushiBite