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

[Solved] Binding a list(of Object) to custom attributtes for the combobox

2 Answers 96 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Tri Nguyen
Top achievements
Rank 1
Tri Nguyen asked on 10 Sep 2009, 03:47 AM
Hello,

How could I populate a custom attributes from a List(of Object)? Let's say that I have an class rComboItem with 3 public properties: Name, Key & Type. After populating a List(of rComboItem), I want to set the Name to the DataTextField property, Key to DataValueField, and Type to Attributes("Type"). Is it possible? Thanks in advance.

Tri

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 11 Sep 2009, 02:21 PM
Hello Tri Nguyen,

Yes, this is possible. You should subscribe to the ItemDataBound event and populate the attribute there. Here is some sample code:

Public Sub RadComboBox1_ItemDataBound(sender As Object, e As RadComboBoxItemEventArgs)
    Dim dataItem As rComboItem = Cast(e.Item.DataItem, rComboItem)
    e.Item.Attributes("Type") = dataItem.Type.ToString()
End Sub

Regards,
Albert,
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tri Nguyen
Top achievements
Rank 1
answered on 11 Sep 2009, 02:58 PM
It works beautifully! Thanks.
Tags
ComboBox
Asked by
Tri Nguyen
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Tri Nguyen
Top achievements
Rank 1
Share this question
or