Link to home
Start Free TrialLog in
Avatar of VBdotnet2005
VBdotnet2005Flag for United States of America

asked on

Checklistbox - clear item

How can I clear all selected items in Checklistbox? I am using VS2005.


    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

        For Each item As ListItem In Me.CheckBoxList1.Items

            If item.Selected Then

                Response.Write(item.ToString & " ")


            End If



        Next

        Me.CheckBoxList1.SelectedItem = -1  ???? error


 
    End Sub
Avatar of j-w-thomas
j-w-thomas

You have to use a loop to clear each one individually.


for i = 0 to Me.CheckBoxList.Items.Count - 1
     
     Me.CheckBoxList.Item(i).Selected = false

next

John
ASKER CERTIFIED SOLUTION
Avatar of j-w-thomas
j-w-thomas

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial