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 8120875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:17:43+00:00 2026-06-06T05:17:43+00:00

This is our code: <div> <table style=width: 349px> <tr> <td class=style1> <asp:ListBox ID=leftbox runat=server

  • 0

This is our code:

  <div>
 <table style="width: 349px">
    <tr>
    <td class="style1">
        <asp:ListBox ID="leftbox" runat="server" Height="114px" Width="212px" 
            SelectionMode="Multiple" AutoPostBack="True">
        </asp:ListBox>
    </td>
    <td>
        <asp:Button ID="Button1" runat="server" Text=">>" onclick="Button1_Click" /><br />
        <asp:Button ID="Button2" runat="server" Text="<<" onclick="Button2_Click" />
    </td>
    <td>
        <asp:ListBox ID="rightbox" runat="server" Height="117px" Width="231px" 
            SelectionMode="Multiple" AutoPostBack="True"></asp:ListBox>
    </td>

    </tr>
</table>
</div>    

The code behind is:

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        List<string> list= GetNameList();
        leftbox.DataSource = list;
        leftbox.DataBind();             
    }
}

private static List<string> GetNameList()
{
    List<string> list = new List<string>();
    list.Add("keerthana");
    list.Add("sirisha");
    list.Add("anusha");
    list.Add("Anuradha");
    list.Add("Bhavani");
    list.Add("divya");
    list.Sort();
    return list;
}

Please tell me how to add two or more selected items one by one from leftbox to rightbox, without using server-side code (as below):

protected void Button1_Click(object sender, EventArgs e)
{
    if (leftbox.SelectedIndex != -1)
    {
        rightbox.Items.Add(leftbox.SelectedItem.Text);
        leftbox.Items.Remove(leftbox.SelectedItem.Text);
    }
}

Thanks in advance…

  • 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-06-06T05:17:44+00:00Added an answer on June 6, 2026 at 5:17 am

    Here is Linq way of get selected items form ListBox

    var selectedItems =  leftbox.Items.OfType<ListItem>().Where(item => item.Selected).ToList();
    

    then you can add all selected values to rightbox and finally remove from leftbox

    EDIT

    protected void Button1_Click(object sender, EventArgs e)
    {
        List<ListItem> selectedItems = new List<ListItem>();
        if (leftbox.SelectedIndex >= 0)
        {
            for (int i = 0; i < leftbox.Items.Count; i++)
            {
                if (leftbox.Items[i].Selected)
                {
                        selectedItems.Add(leftbox.Items[i]);
                }
            }
    
        }
    
        for (int i = 0; i < selectedItems.Count; i++)
        {
            if (!rightbox.Items.Contains(selectedItems[i]))
                rightbox.Items.Add(selectedItems[i]);
            leftbox.Items.Remove(selectedItems[i]);
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In our code we have quite a few cases of this pattern: class outerClass
I'm writing a C code for a class. This class requires that our code
We have this anonymous function in our code, which is part of the jQuery's
i'm wondering about this possibility. Is it possible to make our code written in
I have enabled google Minify in code igniter using this library on our website.
I have code like this which opens Word documents for editing from our intranet,
I saw this code snippet during our lab and it actually compiles in MSVC2008
I ran across this chunk of code (modified) in our application, and am confused
I'm using this code as the starting point to an overhaul of our JavaScript
In many places in our application we have code like this: using(RAPI rapi =

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.