Listbox Loading Listbox

3 posts, 1 answers
  1. Michael
    Michael avatar
    12 posts
    Member since:
    Aug 2010

    Posted 16 Sep 2010 Link to this post

    I'm trying to get information from one list box to populate another list box.  I'm doing a drag and drop from a list box called available to a list box called selected.  After this has been done I would like to populate another list box called selected2 based on what was in the list box called selected.  I'm able of course to get the drap and drop to work but how do you get the id's from the selected list box.

    Thanks,
    Mike
  2. Answer
    Peter
    Admin
    Peter avatar
    6637 posts

    Posted 22 Sep 2010 Link to this post

    Hello Michael,

    Please, refer to the Drag-and-drop demo. You can handle OnDropped for the second ListBox and loop through all its items. I recommend you use the Value property instead of the ID property since the latter is reserved for internal use. Here is a code sample:
    protected void RadListBox_Dropped(object sender, RadListBoxDroppedEventArgs e)
            {
                if (TextBox1.ClientID == e.HtmlElementID)
                {
                    TextBox1.Text = String.Empty;
                    foreach (RadListBoxItem item in e.SourceDragItems)
                    {
                        TextBox1.Text += item.Text + ", \n";
                    }
                    if (TextBox1.Text.Length > 0)
                        TextBox1.Text = TextBox1.Text.TrimEnd(new char[] { ',', ' ', '\n' });
                }
                foreach (RadListBoxItem item in RadListBox2.Items)
                
                    //item.Value
                }
            }



    Kind regards,
    Peter
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Michael
    Michael avatar
    12 posts
    Member since:
    Aug 2010

    Posted 21 Oct 2010 Link to this post

    Thanks for the help.  I ended up using the radlistbox_transferred event.
Back to Top