码迷,mamicode.com
首页 > Web开发 > 详细

mvc 之 @Html.DropDownList

时间:2014-10-07 03:11:32      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   os   ar   sp   div   c   

            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

标签:style   blog   color   io   os   ar   sp   div   c   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!