Asp.net mvc 4 在mvc中将字典列表绑定到dropdownlist

Asp.net mvc 4 在mvc中将字典列表绑定到dropdownlist,asp.net-mvc-4,html.dropdownlistfor,Asp.net Mvc 4,Html.dropdownlistfor,我有需要绑定到mvc中dropdownlist的字典列表 public static readonly Dictionary<string, string> lstGender = new Dictionary<string, string>() { { "M", "Male" }, { "F", "Female" } }; publicstaticreadonly Dictionary lststender=newdictionary(); 如何在mvc中将lstG

我有需要绑定到mvc中dropdownlist的字典列表

public static readonly Dictionary<string, string> lstGender = new Dictionary<string, string>() { { "M", "Male" }, { "F", "Female" } };
publicstaticreadonly Dictionary lststender=newdictionary();
如何在mvc中将lstGender绑定到dropdownlist

public static readonly Dictionary<string, string> lstGender = new Dictionary<string, string>() { { "M", "Male" }, { "F", "Female" } };
提前谢谢你这样做吧

 Dictionary<Int32, string> dict = new Dictionary<int, string>();
            dict.Add(0, "All");
            dict.Add(1, "Male");
            dict.Add(2, "Female");
            dict.Add(3, "Snr Citizen");
            dict.Add(4, "Children");


            ViewBag.Buckets = dict.Select(item => new SelectListItem() { Value = item.Key.ToString(), Text = item.Value });
Dictionary dict=new Dictionary();
添加(0,“全部”);
添加(1,“男性”);
添加(2,“女性”);
增加第(3)款,“公民”;
添加(4,“儿童”);
ViewBag.bucket=dict.Select(item=>newselectListItem(){Value=item.Key.ToString(),Text=item.Value});
鉴于此,我们必须这样做

@Html.DropDownList(“ddlback”,(IEnumerable)ViewBag.bucket)

可能存在的副本