标签: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;
标签:contain foreach type san string put checked for ring
原文地址:http://www.cnblogs.com/CarefulMileage/p/6021108.html