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

Binding to a Tag in a listBox

1 Answer 94 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Scott Gross
Top achievements
Rank 1
Scott Gross asked on 19 Nov 2007, 02:19 AM
I have a busniess Object that I am currently binding to the a RadListBox.

Is there a way to set the Tag of the RadListBoxItem to the BO while binding?

If not does anyone have a better suggestion the a foreach loop and comparing the id (from the value field of the bind) to get the BO of the selection?

Thank you

1 Answer, 1 is accepted

Sort by
0
Angel
Telerik team
answered on 19 Nov 2007, 02:48 PM
Hello Scott Gross,

The ItemDataBound event of RadListBoxElement is raised when a new RadListBoxItem is added, while binding the list box. This is a convenient place to put the code you need to get the job done. Here is an example showing how to subscribe for that event:

C#:
RadListBoxElement listBoxElement = (RadListBoxElement)this.radListBox1.RootElement.Children[0];
listBoxElement.ItemDataBound += new ItemDataBoundEventHandler(onItemDataBound);

VB:
Dim listBoxElement As RadListBoxElement = CType(Me.radListBox1.RootElement.Children(0), RadListBoxElement)
AddHandler listBoxElement.ItemDataBound, AddressOf onItemDataBound


The onItemDataBound event handler receives in its event argument a RadListBoxItem and its corresponding data object. This makes it easy for you to set the property Tag to whatever you need.

If you have any additional questions, please contact us.

Kind regards,
Angel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Scott Gross
Top achievements
Rank 1
Answers by
Angel
Telerik team
Share this question
or