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

[Solved] Problem with SelectedIndexChanged

1 Answer 158 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
ericc34
Top achievements
Rank 1
ericc34 asked on 20 May 2009, 06:33 PM

I have a radcombobox like this :

 

<

 

telerik:RadComboBox ID="rcbClinic" runat="server" Skin="Office2007" Width="300px"

 

 

 

 

 

AutoPostBack="true" HighlightTemplatedItems="true" DataTextField="Title" AllowCustomText="false" DataValueField="ID">

 

 

 

 

 

<itemtemplate>

 

 

 

 

 

<table style="width: 100%; text-align: left">

 

 

 

 

 

<tr>

 

 

 

 

 

<td style="width: 50px; font-size: 11px; font-family: Tahoma; color: Black">

 

 

 

 

<%

# DataBinder.Eval(Container.DataItem, "Date") %>

 

 

</td>

 

 

 

 

 

<td style="width: 100%; font-size: 11px; font-family: Tahoma; color: Black">

 

 

 

 

<%

# DataBinder.Eval(Container.DataItem, "Title") %>

 

 

</td>

 

 

 

 

 

</tr>

 

 

 

 

 

</table>

 

 

 

 

 

</itemtemplate>

 

 

 

 

 

</telerik:RadComboBox>

In this combo I have 2 items like this :

20/05/2009 Clinic 1
20/05/2009 Clinic 1

Each item have an ID (Guid) used like DataValueField but when I enter in my page first time, If I select second Item, SelectedIndexChanged is fire. After this If I select first item, no SelectedIndexChanged event is fired. When I check HTML, I see that value of my combobox is not my Guid but the text of my item selected. Why ????

Is it possible to fired SelectedIndexChanged on each item change even if text is the same ?

Thanks

 

1 Answer, 1 is accepted

Sort by
0
Saed
Top achievements
Rank 1
answered on 20 May 2009, 10:38 PM
Hello there,

SelectedIndexChanged will ONLY fire if a user selects an item. Attempting to change item selection from code WILL NOT fire the event. This is the normal behaviour in ASP my friend, which many developers frequently misinterpret (including myself till I figured that out!).

For example, if you want to make item selection of say Combo2 dependent on item selection of Combo1, selecting an item from Combo1 will change selection of Combo2 as expected. However, changing Combo1 selection will fire the event (caused by you) but changing selection of Combo2 will not fire the event (made via code).

Therefore, you need to keep this in mind when developing your code, which is also true for other controls' events that require user interaction.

Hope this helps.

Regards,
Saed
Tags
ComboBox
Asked by
ericc34
Top achievements
Rank 1
Answers by
Saed
Top achievements
Rank 1
Share this question
or