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

[Solved] Custom Attributes not accessible during SelectedIndexChanged event

1 Answer 263 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Paul Corbett
Top achievements
Rank 1
Paul Corbett asked on 15 Feb 2008, 11:08 AM
Hi,

I am using a radComboBox with LoadOnDemand enabled. During the ItemRequested event I populate the list of items based on the key stroke, when I create the new RadComboBoxItem to add my combo I add a new attribute by

newItem.Attributes["MyAttribute"] = "SomeValue";

I need to access this attribute during the SelectedIndexChanged server event.
When I try

string myAttr = myCombo.SelectedItem.Attributes["MyAttribute"];

I get a null Exception error


thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Veselin Vasilev
Telerik team
answered on 15 Feb 2008, 05:05 PM
Hi Chris Lekkas,

ComboBox items loaded on demand using the ItemsRequested event handler do not exist on the server and cannot be accessed (or their custom attributes) using the server-side FindItemByText / Value methods.

This is needed for speed (otherwise the combobox will not be that responsive upon each keypress if state information and ViewState were persisted).

I suggest that you take a look at this code library: Access Custom Attributes of the Selected Item at Server Side when using Load On Demand

The code is using the "classic" RadComboBox, but I think you will easily get the idea.

Greetings,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox
Asked by
Paul Corbett
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or