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

ComboBox: SelectedItem getting NULL even when it is selected from the list

2 Answers 101 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Chinthana Jayawardena
Top achievements
Rank 1
Chinthana Jayawardena asked on 14 Jul 2009, 05:44 AM
Hi All,

I am yet a trial version user of telerik controls. When I am using it I found an issue as mention below.
My item list is popuplated with a item like 'Investment in Land & Building'
When I select that, it display the text as 'Investment in Land & Building' (This is my exact item text coming from DB)
But when I try to read the property of SelectedItem, it indicates it is NULL. But only Text property filled with the correct selected item's text. And even SelectedIndex is -1.
I believe telerik dropdown control may be using that special character (&), but I am not sure. But I was able to get over the issue by doing some manual check of finding the SelectedItem with Server.HtmlEncode as follows.
eg.(C# Code)
   cmbGlCode.SelectedIndex = cmbGlCode.Items.IndexOf(cmbGlCode.Items.FindItemByText(Server.HtmlEncode(cmbGlCode.Text)));

I am reporting this because I like the controls, and my client is going to buy them.

Regards,
Chinthana

2 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 14 Jul 2009, 09:03 AM
Hi Chinthana Jayawardena,

I suppose you load the items on demand. If that is the case you need to know that items are not accessible on the server-side when loading them on demand

You need to use either Text or SelectedValue properties.

All the best,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Chinthana Jayawardena
Top achievements
Rank 1
answered on 16 Jul 2009, 06:34 AM
Hi Veselin Vasilev,

Items are not loaded on demand or in any web service call(AJAX). This is loaded at the page post back. And this works fine for other telerik dropdowns in the same page, even the issue reported control also works if that particular item is not selected by the user.
What I feel is something to do with the "&" in the items text value.
because this is the only scenario that it fail. As I referred in the previous comment I was able to get over this with HtmlEncode. 

All I can give further info is that these controls are placed inside 2 repeater controls (Parent repeater-> ChildRepeater->Dropdowns). I tried to recreate it without the repeaters it was not reproducible.I believe the only way to recreate it is, by use of repeaters.

Thanks,
Chinthana
Tags
ComboBox
Asked by
Chinthana Jayawardena
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Chinthana Jayawardena
Top achievements
Rank 1
Share this question
or