This is a migrated thread and some comments may be shown as answers.

Listbox Loading Listbox

2 Answers 119 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 16 Sep 2010, 03:21 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 22 Sep 2010, 07:08 AM
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
0
Michael
Top achievements
Rank 1
answered on 21 Oct 2010, 04:05 PM
Thanks for the help.  I ended up using the radlistbox_transferred event.
Tags
ListBox
Asked by
Michael
Top achievements
Rank 1
Answers by
Peter
Telerik team
Michael
Top achievements
Rank 1
Share this question
or