mvc 之 @Html.DropDownList

            Dictionary<string, string> myDic = new Dictionary<string, string>();
            myDic.Add(System.DBNull.Value.ToString(), "---");
            myDic.Add("Male", "");
            myDic.Add("Female", "");
           

            //var items = new List<SelectListItem>()
            //{
            //  (new SelectListItem(){Text = "男", Value = "Male",Selected = false}),
            //  (new SelectListItem(){Text = "女", Value = "female",Selected = true})
            //};

 @Html.DropDownList("sexList", ViewBag.sexList as List<SelectListItem>, new { @class = "l-text required",style = "86px;" })

//用 SelectList 可以生成 selected 效果。  SelectListItem 无效。
// 目前测试的结果是如果 SelectListItem 的 Value 是 integer 转换的可以。 为什么?????????????????
原文地址:https://www.cnblogs.com/starluck/p/4008929.html