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

Casting RadListBox Items

1 Answer 97 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
dexter
Top achievements
Rank 1
dexter asked on 30 Dec 2011, 10:59 AM
Hi there,

Is it possible to cast the items of RadListBox to a Generic list?

Currently, when i populate the RadListBox, i do so:

listBox.DataSource  = ItemList;//ItemList is a Generic list like so: List<ItmList>
listBox.DataBind();


This works fine, but how to i cast the items thats already inside the listbox back to the Generic List(List<ItmList>)?
Hope i can get some help soon.


Regards,
Dexter

1 Answer, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 03 Jan 2012, 12:56 PM
Hi,

In order to make a generic list of RadListBox's items then you could use this approach:
List<RadListBoxItem> collection = new List<RadListBoxItem>();
       collection.AddRange(RadListBox1.Items);

Another solution would be to iterate over the items collection of the RadListBox and create ItmList object for each of the listbox's items and then add it to your List.

Regards,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
General Discussions
Asked by
dexter
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Share this question
or