我想添加項目到DropDownList沒有數據庫。 但輸出只顯示「測試...」ASP.NET MVC如何顯示DropDownList
My Model class。
public class DropDownListData
{
public DropDownListData()
{
City = new List<SelectListItem> { };
}
public List<SelectListItem> City;
}
控制器
public ActionResult Travel()
{
DropDownListData ddld = new DropDownListData();
ddld.City = new List<SelectListItem>
{
new SelectListItem {Value = "Paris" ,Text = "Paris"},
new SelectListItem {Value = "Moscow",Text = "Moscow"},
new SelectListItem {Value = "Yerevan" ,Text = "Yerevan" }
};
return View(ddld);
}
查看
@model ASP.NET.Test.Models.DropDownListData
@{
Layout = null;
}
Testing...
@{
Html.DropDownList("series", Model.City, "Choose City");
}
爲什麼我看不到的DropDownList。我究竟做錯了什麼?