Html.DropDownList()的用法 ( Asp.Net MVC)
来源:互联网 发布:全速网络 待遇如何 编辑:程序博客网 时间:2024/06/10 04:52
Html.DropDownList()赋默认值:
页面代码如下:
<%
List<SelectListItem> list = new List<SelectListItem> {
new SelectListItem { Text = "启用", Value = "0",Selected = true},
new SelectListItem { Text = "禁用", Value = "1" } };
%>//list储存dropdownlist的默认值
<%=Html.DropDownList("state",list,Model.state) %> //state为实体的属性,默认选中"启用"
Html.DropDownList()从数据库读取值:
页面代码如下:
<%= Html.DropDownList("Category", ViewData["Categories"] as SelectList,"--请选择--",new { @class = "my-select-css-class" } )%>
Controllers代码:
public ActionResult Create()
{
List<Category> categories = categoryService.GetAll();
ViewData["Categories"] = new SelectList(categories, "Id", "Name");
return View();
}
- Html.DropDownList()的用法 ( Asp.Net MVC)
- Html.DropDownList()的用法 ( Asp.Net MVC)
- Html.DropDownList()的用法 ( Asp.Net MVC)
- ASP.NET MVC DropDownList 用法
- asp.net mvc dropdownlist
- ASP.NET MVC中DROPDOWNLIST的使用
- ASP.NET MVC中DropDownList的使用
- asp.net mvc Dropdownlist的使用绑定
- ASP.NET MVC DropDownList的使用
- asp.net MVC中html.DropDownList反显
- ASP.NET MVC @Html.DropDownList()如何去掉空白项
- ASP.NET MVC 让@Html.DropDownList显示默认值
- ASP.NET MVC 让@Html.DropDownList显示默认值
- ASP.NET MVC DropdownList 使用
- asp.net mvc Html.BeginForm()用法
- Asp.net MVC HtmlHelper类 @html 用法
- Html.DropDownList()的用法
- Html.DropDownList()的用法
- 移动设备监控软件
- Oracle 外连接和 (+)号的用法
- Apache Tomcat 7.0.20 稳定版发布
- 自动补全
- CMarkup的使用方法
- Html.DropDownList()的用法 ( Asp.Net MVC)
- 对binder驱动的理解
- 自动补全2
- POJ 2482 Stars in Your Window 线段树
- .NET开发不可错过的25款必备工具
- Yii Framework使用经验
- Qt 组合键的实现
- 抛弃WebService 在.NET4中用jQuery调用WCF
- UNIX/LINUX编程学习之进程通信--消息队列