遍历CheckBoxList的方法(读与写)

很多人可能想不到是遍历ListItem li in chkBoxPro.Items这里的Items
foreach (ListItem li in chkBoxPro.Items)
{
    
if (li.Value == arrList[i])
        li.Selected 
= true;
}
private string getTotal()
{
    
int totalNum = 0;
    
for (int i = 0; i < chkBoxPro.Items.Count; i++)
    {
        
if (chkBoxPro.Items[i].Selected)
        {
            totalNum 
+= 1;
        }
    }
    
return totalNum.ToString();
}
原文地址:https://www.cnblogs.com/greatverve/p/1590106.html