views:

37

answers:

2

I have a checkboxlist in a div which shows name gettin data from db. I have to findout the lenght of this checkboxlist on OnSelectedIndexChanged to make some db action on selected item/value. Someone help me out!!!!!

A: 

Presuming your CheckBoxList variable is called checkboxlist use the following to determine the amount of items:

int numberOfItems = checkboxlist.Items.Count

The CheckBoxList.Items property returns a ListItemCollection containing your controls, from here you can use the count property to determine the length of the list or the number of items it contains.

fletcher
So, now how to checked for a particular checkbox for checked or not ?
Fly In SKY
@Fly In SKY - That's a different question. If this question has been answered by any of the solutions posted so far, mark it so and post another question relating to your next problem.
fletcher
A: 
<asp:CheckBoxList id="Check1" RepeatLayout="flow" runat="server" AutoPostBack="true" >
 <asp:ListItem>Item 1</asp:ListItem>
 <asp:ListItem>Item 2</asp:ListItem>
 <asp:ListItem>Item 3</asp:ListItem>
 <asp:ListItem>Item 4</asp:ListItem>
 <asp:ListItem>Item 5</asp:ListItem>
 <asp:ListItem>Item 6</asp:ListItem>
</asp:CheckBoxList>

Protected Sub Check1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Check1.SelectedIndexChanged

Dim items As String = Check1.Items.Count

End Sub

dr.doom