我需要在我的頁面上構建下拉列表。我的目的是根據所選貨幣更新我的網頁上的價格,因此如果用戶將在DDL中選擇$,則會將網頁上的價格更新爲$,如果用戶選擇£,則會以英鎊顯示價格。我的產品的價格(以美元和英鎊計)存儲在數據庫中。MVC4中的下拉列表
任何提示在哪裏可以使用它?
乾杯傢伙
感謝響應@drywoods 到目前爲止,我得到這個: 索引文件
@Html.DropDownList("Currency",
new SelectList(ViewBag.CurrencyList, "Key", "Value"),
new { Class = "ddlStyle" }
)
和控制器:
ViewBag.CurrencyList = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("pound", "£")
, new KeyValuePair<string, string>("dollar", "$")
, new KeyValuePair<string, string>("euro", "€")
};
GetLoadedMVC.Models.CurrencyModel model = new GetLoadedMVC.Models.CurrencyModel();
return View();
所以我在我的頁面上獲得了ddl,但它還沒有做任何事情。 下一步該怎麼辦?