asp.net mvc SelectList使用
2024-08-22 10:43:58
action代码:
BusinessPublicContent pc = db.BusinessPublicContent.Where(m => m.BusinessPublicContentID == id).FirstOrDefault();
ViewBag.data = pc; var query = from m in db.BusinessMenu
where m.Status == && m.IsDelete == && m.ParentBusinessMenuID == select new
{
BusinessMenuID = m.BusinessMenuID,
BusinessMenuName = m.BusinessMenuName
}; List<SelectListItem> items = new SelectList(query.ToList(), "BusinessMenuID", "BusinessMenuName",id).ToList(); ViewBag.items = items;
html代码:
@Html.DropDownList("mid", ViewBag.items as IEnumerable<SelectListItem>)
最新文章
- javaScript代码执行顺序
- JavaScript Patterns 5.7 Object Constants
- 文件上传和下载(可批量上传)——Spring(二)
- nodejs将PDF文件转换成txt文本,并利用python处理转换后的文本文件
- pip安装使用详解
- linux 下安装rsync
- js小分享
- poj1623 Squadtrees
- LeeCode-Invert Binary Tree
- codeforces 597B Restaurant
- Struts2第五篇【类型转换器、全局、局部类型转换器】
- HashSet实现不重复储值原理-附源码解析
- Java 8的用法(泛型接口,谓词链)
- PLSQL创建Oracle定时任务
- PYthon3:简单几步实现冒泡排序
- varnish 相关说明
- topological sort
- Zookeeper-watcher机制源码分析(一)
- Keepalived+LVS高可用负载均衡集群
- PHP自定义curl请求