0
我是MVC的新手,我對如何將模型作爲下拉列表傳遞給視圖存在問題。我有兩個這樣的模型...我怎樣才能將模型作爲MVC中的下拉列表傳遞給我
public class CarModel
{
public int Id {get set;}
public string Manufacturer {get;set;}
}
public class Fuel
{
public int Id {get;set;}
public string FuelType {get;set;}
}
public ActionResult()
{
//some logic here
return View("Home", carModel)
}
And here is the view ..
@model myproject.Models.CarModel
<div class="row">
<div class="col-md-3">
@Html.LabelFor(m => m.Manufacturer)
</div>
<div class="col-md-9">
@Html.EditorFor(m => m.Manufacturer)
</div>
</div>
我需要添加一個fueltype下拉列表,列出來自數據庫的fueltypes。但我對如何我可以訪問這裏的燃油型號不確定...
<div class="row">
<div class="col-md-3">
@Html.LabelFor(m => m.FuelType)
</div>
<div class="col-md-9">
@Html.DropDownListFor(m => m.FuelType)
</div>
</div>
什麼將是我通過燃油型號,查看並列出在下拉列表結果的最佳方式?
謝謝
的可能的複製[ASP.NET MVC - 查看與多個模型(http://stackoverflow.com/questions/944334/asp-net-mvc-view -with-多型號) – Krishna