我是ASP.NET MVC的新手,有以下情況。我需要一些幫助來創建適當的模型或視圖。ASP.NET MVC4返回列表<T>從查看回到模型
我現在有下面的模型。
public class ExtrasModel
{
public List<ExtraItem> ExtraItems { get; set; }
public DateTime FlightArrivalTime { get; set; }
public PickupInfoType PickupInfo {get; set; }
}
public class ExtraItem
{
public string ExtraInfo { get; set; }
public int ProdExtraId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public double Cost { get; set; }
public int CostType { get; set; }
public string Currency { get; set; }
public int Quantity { get; set; }
public double TotalCost { get; set; }
}
額外資源列表將從數據庫中提取。
這是我怎麼也查看:
@foreach(var extra in Model.ExtrasList)
{
<tr>
<td>
//Not sure what code to put here
@Html.DropDownListFor(p => p.ExtrasList, new SelectList(listItems, "Value", "Text", extra.Quantity), new { id = extra.ProdExtraId })
</td>
<td>@extra.Name</td>
<td>@string.Format("{0} {1}", extra.Cost, extra.Currency)</td>
</tr>
}
現在如何使視圖返回與選擇演員的數量模型?
在此先感謝!