如何得到checklistbox被选中的个数?

解决方案 »

  1.   

            int m = 0; //记录被选中的个数
            for (int i = 0; i < CheckBoxList1.Items.Count; i++)
            {
                if (CheckBoxList1.Items[i].Selected)
                {
                    m++;
                }
            }
      

  2.   


        function chkDelLength() {
            var chkLenth = 0;
            for (i = 0; i < document.getElementsByName("chkDel").length; i++) {
                if (document.getElementsByName("chkDel")[i].checked) {
                    chkLenth++;
                }
            }
            return chkLenth;
        }
      

  3.   


    function getSelCount()
    {
       return $('input[id*=checklistboxname][:checked]').length;
    }