How to loop through a checkboxlist and to find what's checked and not checked?

后端 未结 6 2155
-上瘾入骨i
-上瘾入骨i 2020-12-18 18:47

I\'m trying to loop through items of a checkbox list. If it\'s checked, I want to set a value. If not, I want to set another value. I was using the below, but it only gives

6条回答
  •  一向
    一向 (楼主)
    2020-12-18 19:28

    Try something like this:

    foreach (ListItem listItem in clbIncludes.Items)
    {
        if (listItem.Selected) { 
            //do some work 
        }
        else { 
            //do something else 
        }
    }
    

提交回复
热议问题