Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6012477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:24:37+00:00 2026-05-23T02:24:37+00:00

I have a checkboxlist whith several options. The option(s) selected is/are removed from a

  • 0

I have a checkboxlist whith several options. The option(s) selected is/are removed from a second checkboxlist. This works fine in the below code. The problem is when the user changes the selected option in checkboxlist 1 the second checkboxlist still has the original option removed. How can I change this? Note: the dropdownlist helps the user continue with the form.

page.aspx

   <asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="true">           <asp:ListItem Value="3">Italian</asp:ListItem>
    <asp:ListItem Value="6">Chinese</asp:ListItem>
    <asp:ListItem Value="7">Japanese</asp:ListItem>
    <asp:ListItem Value="8">Russian</asp:ListItem>
    <asp:ListItem Value="9">Arabic</asp:ListItem>
    <asp:ListItem Value="10">Hebrew</asp:ListItem>
    <asp:ListItem Value="11">Persian</asp:ListItem>
    <asp:ListItem Value="12">Turkish</asp:ListItem>
    </asp:CheckBoxList>

…

       <asp:DropDownList ID="DropDownList1" Width="100px" runat="server"  AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
  <asp:ListItem Value="">Select</asp:ListItem>
  <asp:ListItem Value="Yes">Yes</asp:ListItem>
  <asp:ListItem Value="No">No</asp:ListItem>
   </asp:DropDownList>   

page.aspx.vb

   Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged

    Dim li2 As ListItem
    Dim values As String = ""

    For i As Integer = 0 To CheckBoxList1.Items.Count - 1
        If CheckBoxList1.Items(i).Selected Then
            values += CheckBoxList1.Items(i).Value + ","
        End If
    Next

    values = values.TrimEnd(","c)
    Dim ints As String() = values.ToString.Split(",")
    Dim y As Integer

    If DropDownList1.SelectedValue = "Yes" Then
    For y = 0 To UBound(ints)
            li2 = CheckBoxList2.Items.FindByValue(ints(y))
            If Not IsNothing(li2) Then
                CheckBoxList2.Items.Remove(li2)
            End If
      Next
  end if

  End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:24:38+00:00Added an answer on May 23, 2026 at 2:24 am

    The most simple solution is to set EnableViewState="false" in CheckBoxList2.

    But i’m afraid that this may cause you other trouble. If so, you’ll need to persist the full list of items in CheckBoxList2 across postbacks, or at least those items that share values with CheckBoxList1 (and can be removed). If the labels of these shared items are the same too, you can use CheckBoxList1 to recreate the shared items in CheckBoxList2, before removing the checked items. This way you wouldn’t need to persist additional data.

    But I wouldn’t make this thing too complex. Clearing the CheckBoxList2, retrieving and adding all items, and removing the ones checked in CheckBoxList1 may be the best way to go. In addition, you may want to store and reapply the selected state of the items in CheckBoxList2.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes one is derived from CheckBoxList and the second one from
I have this CheckBoxList on a page: <asp:checkboxlist runat=server id=Locations datasourceid=LocationsDatasource datatextfield=CountryName datavaluefield=CountryCode />
I'm having trouble figuring this out. If I have a checkboxlist inside a usercontrol,
I have this modalPopupExtender, I want it to show a CheckBoxList with some data.
I have an ASP.NET server control that inherits from CheckBoxList that renders the controls
Hey there, i got this very annoying problem: I have a CheckBoxList getting items
I have a checkboxlist in ASP.net with several choices in it. Is there a
I have a CheckBoxList where users can select multiple items from the list. I
I have a CheckBoxList that displays a list of checkboxes using data from a
I have the following sample code which gets a list of values from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.