码迷,mamicode.com
首页 > Web开发 > 详细

MVC 使用Checkbox

时间:2016-11-01 23:50:38      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:contain   foreach   type   san   string   put   checked   for   ring   

选中checkbox

 

页面:

@foreach (string item in ViewBag.ListItem)
{
<input type="checkbox" value="@item" name="@item" @(ViewBag.CheckListItem.Contains(@item)==true?"checked=‘checked‘":"") />@item
}

 

Controller:

List<string> ListItem = new List<string> { "zhangsan", "lisi", "wangwu", "maliu", "li" };
List<string> checkListItem = new List<string> { "lisi", "wangwu" };
ViewBag.ListItem = ListItem;
ViewBag.checkListItem = checkListItem;

MVC 使用Checkbox

标签:contain   foreach   type   san   string   put   checked   for   ring   

原文地址:http://www.cnblogs.com/CarefulMileage/p/6021108.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!