Our combobox is set to autopostback and update a radlistbox of available items to select from. However, if "Select State" is visible in the combobox and the user selects a state, the SelectedIndexChanged event is not fired and as a result, the radlistbox is not filled with the data. However, if the combobox is changed again to a different state, then the event fires. If valid data is the selected item in the combobox and there is no default item, then the event is fired.
Understanding that the DefaultItem isn't part of the indexed items in the combobox, I can *sort of* understand why the event isn't firing, however, that doesn't resolve the issue that I need to postback whenever the user selects a valid item from the combobox.
How can I get a postback whnenver an item is selected in a combobox (not the default item) when the value being changed from is the default item?
12 Answers, 1 is accepted

The client side and server side SelectedIndexChanged events wont fire when the default item is selected (even if the AutoPostBack property is set to true). This is the default nature and these events will fire instantly once an item other than the default item in the RadComboBox is selected. For these events to fire, it does not require something like what you described : the user need to select an item when the RadComboBox has its default item set and again on selecting another item these events will fire. Please have a look at the following sample code which works as expected.
ASPX:
<
telerik:RadComboBox
ID
=
"RadCombobox1"
runat
=
"server"
AutoPostBack
=
"true"
Skin
=
"Outlook"
OnClientSelectedIndexChanged
=
"OnClientSelectedIndexChanged"
OnSelectedIndexChanged
=
"RadCombobox1_SelectedIndexChanged"
>
<
DefaultItem
runat
=
"server"
Text
=
"Select States"
/>
<
Items
>
<
telerik:RadComboBoxItem
runat
=
"server"
Text
=
"State 1"
/>
<
telerik:RadComboBoxItem
runat
=
"server"
Text
=
"State 2"
/>
<
telerik:RadComboBoxItem
runat
=
"server"
Text
=
"State 3"
/>
</
Items
>
</
telerik:RadComboBox
>
Thanks,
Shinu.

Steps to recreate the problem.
1) Populate the RadComboBox with items in the codebehind by binding a datatable to it.
2) Set the DefaultItem text and value, then set it to be selected.
When viewing the page, select the first item in the RadComboBox that IS NOT the default item. SelectedIndexChanged DOES NOT fire.
Select any other item in the list. SelectedIndexChanged DOES fire.
Refresh the page so that the DefaultItem is visible in the RadComboBox, then select any item other than the first item in the list that IS NOT the default item. The SelectedIndexChanged event DOES fire.
Just so we are clear, I am not selecting the default item from the list, I am selecting something else from the list.
An additional reason for me to believe this is a bug is that the client side event "OnClientSelectedIndexChanged" does fire.

Incidently, the code you provided does not work. If you use that code, then select "State 1" from the combobox, the server side event does not fire on postback. Postback does occur however.
If you select any other item from the combobox, the event will fire.
In the meantime, I am using this as a workaround:
if
(Request.Form[
"__EVENTTARGET"
] ==
"RadComboBox1"
) {
RadComboBox1_SelectedIndexChanged(RadComboBox1,
new
EventArgs);
}
This works for me because this is the only event I am handling. Also, to make this work properly, I had to remove the event handlers from the webpage.
I have tested the provided code snippet from Shinu and it seems to behaves correctly at my end. Here is a video, demonstrating it. Please correct me if I had missed something or doing anything wrong.
Regards,
Nencho
Telerik

Actually I may know what is causing the problem, but I don't have the internal knowledge of the control to investigate it.
Consider the bug that is present when DefaultItem.Selected = True is issued and later the user issues RadComboBox.SelectedIndex = n ... unless the programmer first sets DefaultItem.Selected = False, the item set by RadComboBox.SelectedIndex = n will not be displayed and the DefaultItem will remain visible.
Perhaps the issue is that the list default item displays whenever the combobox is rendered and overrides the selectedindex value, but that would not explain why it works in your development environment, but not for me.
Please see my test here
Can you verify the Telerik.Web.UI.dll version you are using?
I noticed that you had described this problematic behavior in the other submitted forum ticket. I would like to ask you to continue our conversation in the other thread, in order to keep the correspondence consistent.
Regards,
Nencho
Telerik

Where did you put this code? I would like to use this workaround since I'm not able to determine why sometimes the event is triggered and sometimes is not.
The code snippet that Keith demonstrated is used at the Page_Load event, in order to track if the currently triggered postback is caused by the ComboBox and if so - to subscribe for the SelectedIndexChanged event handler.
However, I would like to ask you to elaborate a bit more on your proper scenario. Do you use DefaultItem? In addition, please demonstrate the implementation of the RadComboBox that you use at your end and the scenario, where the issue occurs. Also, specify which version of our controls are you currently using.
Regards,
Nencho
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Hi Nencho,
I was actually looking for alternatives, I tried using OnItemChecked instead of the SelectedIndexChanged, but the performance wasn't as good as expected causing more issues.
Now, I'm not using DefaultItem, but I'm manually checking the items of the ComboBox the first time the page is loaded based on the cookies saved before, this is order to help the users to remember the last selection they did:
public static void SetCheckedItems(RadComboBox comboBox, string sSelectedValues, string sDataType)
{
string[] sValues = _common.SplitWords(sSelectedValues);
foreach (string sValue in sValues)
{
if (sValue != String.Empty)
{
RadComboBoxItem item;
if (sDataType.Trim().ToLower() == "string")
item = comboBox.FindItemByText(sValue);
else
item = comboBox.FindItemByValue(sValue);
if (item != null)
{
item.Selected = true;
item.Checked = true;
}
}
}
}
This works fine but I cannot find why sometimes the event just doesn't fired at all, I have an stop when the event is fired (SelectedItemChanged) and sometimes when I start testing the control, just doesn't get fired... Now if this issue is related to the manual "checking" of the items, is there any way to save the checked values using the control itself? so it can remember for days the selection made?
I'm using the latest version of the controls 2015.1.401.45
Setting the selected items in the code-behind should not have any effect on whether the event will fire or not. We would like to further investigate why the event is not always firing at your side. I would ask you to isolate a sample project that reproduces the issue, open a support ticket and attach it, because the forum does not allow projects to be attached.
Regards,
Ivan Danchev
Telerik
See What's Next in App Development. Register for TelerikNEXT.

so 2009 version has java script issues [set checked not working].
It wont even allow you to have server side event.
so what level of testing done for this version.
We are facing issues while migrating.
If I change telerik version ,I have to test entire fuctionality.
Finally using telerik becomes Pathetic choice.
Could you please elaborate more on the issue you are experiencing and specify the exact version of the Telerik controls you are using?
Our controls are thoroughly tested, but it is possible that changes to their functionality or appearance might cause some unexpected and unintended effect when upgrading from such an old version (2009) to the latest. We recommend keeping your controls updated as various improvements and new features are regularly added in subsequent versions.
Please, find linked the following blogpost, which would help you isolate the issue you are having in a sample project and post it for further review.
Regards,
Ivan Danchev
Telerik