Html.DropDownList
//获取直属父级列表
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的更多相关文章
- Asp.Net 将枚举类型(enum)绑定到ListControl(DropDownList)控件
在开发过程中一些状态的表示使用到枚举类型,那么如何将枚举类型直接绑定到ListControl(DropDownList)是本次的主题,废话不多说了,直接代码: 首先看工具类代码: /// <su ...
- DropDownList 下拉框选择改变,促发事件和防全局刷新(记录)
代码: <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:Script ...
- DropDownList实现可输入可选择
1.js版本 <div style="z-index: 0; visibility: visible; clip: rect(0px 105px 80px 85px); positio ...
- js给DropdownList赋值
", "model": "APOLLO M/B1"}]; ; i < row.length; i++) { var addOption = do ...
- ASP.NET MVC 让@Html.DropDownList显示默认值
在使用@Html.DropDownList的过程中,发现它的用法很局限,比如在加载的时候显示设定的默认项或者调整它的显示样式,在网上查了一些资料,终于把这个问题解决了. 一.View代码 @using ...
- GridView中实现DropDownList联动
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- "不能在 DropDownList 中选择多个项。"其解决办法及补充
探讨C#.NET下DropDownList的一个有趣的bug及其解决办法 摘要: 本文就C#.Net 环境下Web开发中经常使用的DropDownList控件的SelectedIndex属性进行了详细 ...
- Asp.net mvc页面传值-- dropdownlist
后台传值 List<ConfigParamInfo> paramList = configParamBLL.GetModelList(" and parentID=1" ...
- 怎么取得dropdownlist选中的ID值
把数据库绑定在dropdownlist中,然后把选中的dropdownlist的项的ID值保存在另外的一个数据库中.怎么取得dropdownlist选中的ID值呢?? this.DropDownLis ...
- MVC5中后台提供Json,前台处理Json,绑定给Dropdownlist的例子
MVC5中后台提供Json,前台处理Json,绑定给Dropdownlist的例子: 前端: 我们以前在前端定义了两个控件: <div class="row"> < ...
随机推荐
- [DabaBase] MongoDB (6) 启动、停止、相关系统配置及安全性设置
MongoDB 启动.停止.相关系统配置及安全性设置 启动MongoDB ./mongod —-help 查看帮助说明 mac-abeen:bin abeen$ sudo ./mongod --dbp ...
- linux问题
make:进入目录'/opt/FriendlyARM/tiny4412/05android/android-4.1.2'target Dex: framework trouble writing ou ...
- Android动态方式破解apk终极篇(加固apk破解方式)
一.前言 今天总算迎来了破解系列的最后一篇文章了,之前的两篇文章分别为: 第一篇:如何使用Eclipse动态调试smali源码 第二篇:如何使用IDA动态调试SO文件 现在要说的就是最后一篇了,如何应 ...
- 如何使用xshell远程连接ubuntu
在Ubuntu上安装ssh就可以使用xshell登录了,安装步骤: 1,sudo apt-get install openssh-server 2,然后启动ssh sudo /etc/init.d/s ...
- ooize的使用01
1.常用的调度框架 1.1 linux crontab 1.1.1 编写一个crontab,每一分钟向/opt/data/cronlogs文件中添加当前时间 crontab -e
- SQL(oracle) 取得分组后最大值记录
方法一 select t1.a,t1.b,t1.c from test t1 inner join (seelct a,max(b) as b from test group by a) t2 on ...
- 开始学习Angular Mobile UI
介绍 Mobile AngularUI 可以让你使用Twitter Booostrap和Angular JS来开发混合移动App和桌面应用程序. 下面是是一些贯穿整个项目的步骤,我强烈的建议你去继续阅 ...
- 准备阶段-mongodb数据库安装
具体安装步骤,请参阅 mongoDB(win7_64位)使用手册1.0
- python之初级学习
一.python安装 1.下载安装包(本人使用python3.5.1) https://www.python.org/downloads/ 2.安装python-3.5.1.exe 本人下载的是pyt ...
- Cheatsheet: 2016 08.01 ~ 08.31
.NET Getting Started with ASP.NET Core and VS Code Coding Standard Best Practices In C# Wire – Writi ...