遍历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();
}
posted @ 2009-10-26 17:33  大气象  阅读(1406)  评论(2编辑  收藏  举报
http://www.tianqiweiqi.com