作者热门文章
- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在尝试遍历复选框列表的项目。如果选中,我想设置一个值。如果没有,我想设置另一个值。我使用的是下面的,但它只给我勾选的项目:
foreach (DataRowView myRow in clbIncludes.CheckedItems)
{
MarkVehicle(myRow);
}
最佳答案
这将给出一个选定的列表
List<ListItem> items = checkboxlist.Items.Cast<ListItem>().Where(n => n.Selected).ToList();
这将给出所选框值的列表(如果需要,更改文本的值):
var values = checkboxlist.Items.Cast<ListItem>().Where(n => n.Selected).Select(n => n.Value ).ToList()
关于c# - 如何遍历复选框列表并找到已选中和未选中的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/395454/
我是一名优秀的程序员,十分优秀!