我需要在我的页面上构建下拉列表。我的目的是根据所选货币更新我的网页上的价格,因此如果用户将在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,但它还没有做任何事情。 下一步该怎么办?