//获取直属父级列表
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.DropDownList的更多相关文章

  1. Asp.Net 将枚举类型(enum)绑定到ListControl(DropDownList)控件

    在开发过程中一些状态的表示使用到枚举类型,那么如何将枚举类型直接绑定到ListControl(DropDownList)是本次的主题,废话不多说了,直接代码: 首先看工具类代码: /// <su ...

  2. DropDownList 下拉框选择改变,促发事件和防全局刷新(记录)

    代码: <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:Script ...

  3. DropDownList实现可输入可选择

    1.js版本 <div style="z-index: 0; visibility: visible; clip: rect(0px 105px 80px 85px); positio ...

  4. js给DropdownList赋值

    ", "model": "APOLLO M/B1"}]; ; i < row.length; i++) { var addOption = do ...

  5. ASP.NET MVC 让@Html.DropDownList显示默认值

    在使用@Html.DropDownList的过程中,发现它的用法很局限,比如在加载的时候显示设定的默认项或者调整它的显示样式,在网上查了一些资料,终于把这个问题解决了. 一.View代码 @using ...

  6. GridView中实现DropDownList联动

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  7. "不能在 DropDownList 中选择多个项。"其解决办法及补充

    探讨C#.NET下DropDownList的一个有趣的bug及其解决办法 摘要: 本文就C#.Net 环境下Web开发中经常使用的DropDownList控件的SelectedIndex属性进行了详细 ...

  8. Asp.net mvc页面传值-- dropdownlist

    后台传值 List<ConfigParamInfo> paramList = configParamBLL.GetModelList(" and parentID=1" ...

  9. 怎么取得dropdownlist选中的ID值

    把数据库绑定在dropdownlist中,然后把选中的dropdownlist的项的ID值保存在另外的一个数据库中.怎么取得dropdownlist选中的ID值呢?? this.DropDownLis ...

  10. MVC5中后台提供Json,前台处理Json,绑定给Dropdownlist的例子

    MVC5中后台提供Json,前台处理Json,绑定给Dropdownlist的例子: 前端: 我们以前在前端定义了两个控件: <div class="row"> < ...

随机推荐

  1. fnciton

    -----oracle将字段字符分隔作为临时表 select column_value as site_id from table (select fn_split_clob(dashboard_pr ...

  2. Maven常用的命令

    mvn archetype:generate 产生一个新的项目 mvn compile 会执行 mvn resources:resources    mvn compiler:compile两个过程 ...

  3. 2017年1月4日 16:16:24开始学习Linux——好像回到上次发随笔的时间。

    auto为C语言局部变量的默认属性 static指明变量的静态属性,也具有作用域限定符的意义 static修饰的全局变量作用域只是生命的文件中,修饰的函数作用域只是声明的文件中 register指明将 ...

  4. FPGA重要设计思想

    FPGA重要设计思想   1.速度和面积互换原则.以面积换速度可以实现很高的数据吞吐率,其实串/并转换.就是一种以面积换速度的思想 2.乒乓操作. 3.串/并转换的思想. 高速数据处理的重要技巧之一. ...

  5. JAVA微信支付多次回调方法解决方案

    @WebServlet("/ActionServlet")public class PayWxOrderingReqCBS extends HttpServlet { public ...

  6. LookUpEditPopup自动调整宽度

    this.Properties.BestFitMode = BestFitMode.BestFitResizePopup;

  7. ichart.js绘制虚线 ,平均分虚线

    var Data=new Array(); Data[0] = { labels : ["第一单元","第二单元","第三单元"," ...

  8. jsp发布:Could not publish server configuration: null. java.lang.NullPointerException

    1.jsp发布: Could not publish server configuration: null. java.lang.NullPointerException

  9. Deep Learning 18:DBM的学习及练习_读论文“Deep Boltzmann Machines”的笔记

    前言 论文“Deep Boltzmann Machines”是Geoffrey Hinton和他的大牛学生Ruslan Salakhutdinov在论文“Reducing the Dimensiona ...

  10. 解决JS加载速度慢

    在网页中的js文件引用会很多,js引用通常为 <script src="xxxx.js"></script> 通过如下方法可以增加js加载速度 <sc ...