MVC dropdownlist 下拉框

List<SelectListItem> items = new List<SelectListItem>();

 items.Add(new SelectListItem() { Text = " - ", Value = "", Selected = true });
items.Add(new SelectListItem() { Text = "", Value = 1);
items.Add(new SelectListItem() { Text = "", Value = 2);
ViewData["sex"] = items;

 

VIEW

<style>

        .select {
            height: 28px;
            width: 248px;
            border-radius: 5px;
            border: 1px solid #ccc;
            box-shadow: 2px 2px 3px #e5e5e5;
            margin-left: 20px;
        }
</style> 

@Html.DropDownList("sex", null, new { @class = "select" })

 

posted @ 2017-04-19 18:04  Hao0  阅读(203)  评论(0编辑  收藏  举报