Checklistbox - clear item

Posted on 2007-10-21
Last Modified: 2008-01-09
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


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

    End Sub
Question by:VBdotnet2005
    LVL 3

    Expert Comment

    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


    LVL 3

    Accepted Solution

    Sorry correct that, it should be "...Items(i)..."

    Me.CheckBoxList.Items(i).Selected = false

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
    I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now