how to get selected items count in asp:checkboxlist

前端 未结 4 1538
离开以前
离开以前 2021-02-15 18:01

i have a checkboxlist control

 
 

4条回答
  •  日久生厌
    2021-02-15 18:31

    We will iterate through the checkboxlist and use a counter variable for counting selected items. For every item in checkboxlist we will add 1 to counter variable selCount if item is checked

    int selCount = 0;   
    
    for(int i= 0; i< chklst.Items.Count; i++) 
      if(chklst.Items[i].Selected)
          selCount++;
    

    // Now selCount will contain the count of selected items

提交回复
热议问题