Tips:ColumnScope为checkBoxlist名称
1 选中所有项
foreach (ListItem item in this.ColumnScope.Items)
{
item.Selected = true;
}
2 取消选中所有项
foreach (ListItem item in this.ColumnScope.Items)
{
item.Selected = false;
}
3获取选中项的所有值
for (int i = 0; i < ColumnScope.Items.Count; i++)
{
if (this.ColumnScope.Items[i].Selected)
{
tempColumnScope += this.ColumnScope.Items[i].Value + ";"; //累加选中项的值
}
}
4checkoboxlist相关属性
RepeatDirection="Horizontal" RepeatLayout="Flow" //项水平显示
RepeatColumns="5" //每行显示5项
CellPadding="20" CellSpacing="10" //每个项之间的间距 (一些浏览器中无效)
本文介绍了如何使用CheckBoxlist进行批量操作,包括选中所有项、取消选中所有项以及获取当前选中项。通过实例代码演示了如何遍历CheckBoxlist,设置和检查项的选择状态。
280

被折叠的 条评论
为什么被折叠?



