Html.DropDownList
2016-07-19 16:17
357 查看
//获取直属父级列表 var parents = _MemberEditDTOService.GetParents(); var parentsItems = parents.Result.Select(s => new SelectListItem() { Text = s.MemberName, Value = ((int)s.Id).ToString() }).ToList(); //parentsItems.First(t => t.Value.Equals("0")).Text = "--请选择--"; ViewBag.parentsSelectItems = parentsItems;
前端:
@Html.DropDownList("MemberTypesSelectItems", ViewBag.MemberTypesSelectItems as SelectList, new { id = "memberTypes", Class = "form-control ", style = "display: inline-block;" })
或者
@Html.DropDownList("BusinessDepartment", new List<SelectListItem> { (new SelectListItem() {Text = "--请选择--", Value = "", Selected = true}), (new SelectListItem() {Text = "业务部1", Value = "1", Selected = false}), (new SelectListItem() {Text = "业务部2", Value = "0", Selected = false}), }, new { @style = "width:99%;" }, new { id = "BusinessDepartment" })
或者
<select id="ddlUserType" class="form-control " style="width: 90px; display: inline-block;"> @foreach (var userType in ViewBag.UserType) { <option value="@userType.Value">@userType.Text</option> } </select>
相关文章推荐
- 浏览器是怎样工作的:渲染引擎,HTML解析(连载二)
- KindEditor--开源的在线HTML编辑器
- HTML 列表切换
- jemter使用-9、生成html报告图表指示板
- 本地,怎么把自己做的html页面放到某个域下呢?
- $(this.el).html 与 this.$el.tml区别
- html图片如何等比缩放
- html中offsetTop、clientTop、scrollTop、offsetTop各属性介绍
- html中offsetTop、clientTop、scrollTop、offsetTop各属性介绍
- HTML代码中IMG标签的全部属性
- XZ_HTML之HTML列表
- DEDECMS教程:织梦栏目更新HTML出现“模板文件不存在,无法解析文档”的解决方法(转)
- 把office文档转换为html过程中的一些坑
- html中的a标签(超链接)的使用
- html浏览器
- HTMLParser使用--只是为了保存
- HTML之class属性、table元素、块级和内联元素
- HTML与SEO的学习之路
- html
- HTML代码教程