首页 > Web开发 > 详细

mvc 之 @Html.DropDownList

时间:2014-10-07 01:54:52      阅读:313      评论:0      收藏:0      [点我收藏+]
            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 = "width:86px;" })

//用 SelectList 可以生成 selected 效果。  SelectListItem 无效。
// 目前测试的结果是如果 SelectListItem 的 Value 是 integer 转换的可以。 为什么?????????????????

 

mvc 之 @Html.DropDownList

原文:http://www.cnblogs.com/starluck/p/4008929.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!