How to select/remove the item from list box (single selection mode)?

Posted on 2006-05-30
Last Modified: 2010-06-08
I need to move item from listBox1 to listBox2.
Both list boxes are in single selection mode.

Clicks the item1 in ListBox1 and button Add, it works. The item is removed from listBox1 and appears in listBox2.
Clicks the item2 in listBox1 and button  Add, it fails. The error message:

System.Web.HttpException: Cannot have multiple items selected when the SelectionMode is Single.

How do I fix this?
Question by:chuang4630
    LVL 20

    Accepted Solution

    Sorry I found this also I got around it in that code I just posted you with this

        protected void Button2_Click(object sender, EventArgs e)
            ListItem item = ListBox1.SelectedItem;
            ListBox2.Items.FindByText(item.Text).Selected = false;


     ListBox2.Items.FindByText(item.Text).Selected = false; <--------------------------------
    LVL 20

    Expert Comment

    Do you need anymore assistance with this one?

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    746 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

    15 Experts available now in Live!

    Get 1:1 Help Now