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

RadComboBox stops working after adding SelectedItemChanged code

4 Answers 61 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
dean.carrefour
Top achievements
Rank 1
dean.carrefour asked on 04 Aug 2011, 06:54 PM
I have a very plain drop down with only a few entries.  Before this morning, the list is populated and you could click on any entry and nothing happened...which was fine because there was no code.  Now I want it to do something when one of the list items is selcted (redirect to another page).  So I added OnSelectedItemChanged = "RadComboBox1_OnSelectedItemChanged" to the html definition of the combobox, then in the code behind I have a function to match that does a Select Case statement and redirects to the appropriate page based on which item the user selects.

Now that I've added this code I can't click on the ComboBox anymore.  It doesn't drop-down like it should.

HTML Page:
Choose Location: 
<telerik:RadComboBox ID="RadComboBox1" Runat="server" DropDownWidth="200px"
    EnableTextSelection="False" Height="50px" MaxHeight="200px" NoWrap="True"
    Width="200px" OnClientSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
    <Items>
        <telerik:RadComboBoxItem runat="server" Text="Atlanta" Value="ATL" />
        <telerik:RadComboBoxItem runat="server" Text="Cincinnati" Value="CIN" />
        <telerik:RadComboBoxItem runat="server" Text="Cleveland" Value="CLV" />
        <telerik:RadComboBoxItem runat="server" Text="Dayton" Value="DAY" />
        <telerik:RadComboBoxItem runat="server" Text="Kansas City" Value="KC" />
        <telerik:RadComboBoxItem runat="server" Text="Kansas" Value="KAN" />
        <telerik:RadComboBoxItem runat="server" Text="Memphis" Value="MEM" />
        <telerik:RadComboBoxItem runat="server" Text="Northeast Ohio" Value="NEO" />
        <telerik:RadComboBoxItem runat="server" Text="Oklahoma City" Value="OKC" />
        <telerik:RadComboBoxItem runat="server" Text="Philadelphia" Value="PHL" />
        <telerik:RadComboBoxItem runat="server" Text="St. Louis" Value="STL" />
    </Items>
</telerik:RadComboBox>



Code Behind .aspx page:
    Protected Sub RadComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles RadComboBox1.SelectedIndexChanged
        Select Case e.Value
            Case "ATL"
 
            Case "CIN"
 
            Case "CLV"
                Response.Redirect("http://www.someurl.com/CLV.asp")
 
            Case "DAY"
 
            Case "KAN"
 
            Case "KC"
 
            Case "MEM"
 
            Case "NEO"
 
            Case "OKC"
 
            Case "PHL"
 
            Case "STL"
 
        End Select
    End Sub
End Class

4 Answers, 1 is accepted

Sort by
0
Thad
Top achievements
Rank 2
answered on 04 Aug 2011, 08:31 PM
Hi Dean,

You are setting the OnClientSelectedIndexedChange property, but have your code server side in the code behind.  The OnClientSelectedIndexedChange property is for attaching a JavaScript function -- for example if you wanted to pop up the question "Are you sure you wanted to do that?"...

Change the RadComboBox definition to the following and you should be good.
OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"

Hope that helps!
Thad
0
dean.carrefour
Top achievements
Rank 1
answered on 04 Aug 2011, 09:25 PM
That got the combobox to work again when I click on it, but if I choose Cleveland, it should take it to my code behind and redirect it, but that even never fires.
0
Thad
Top achievements
Rank 2
answered on 04 Aug 2011, 09:40 PM
Hi Dean,

Sorry about that - I forgot to mention that you needed to set AllowAutoPostBack="true" as well.  That will actually tell the RadComboBox to post back when the selection changes -- the OnSelectedIndexChanged property tells the server side code which event to invoke when it posts back...

That should get you going!
Thad
0
dean.carrefour
Top achievements
Rank 1
answered on 04 Aug 2011, 10:03 PM
That worked.  Duh!  Thanks.
Tags
ComboBox
Asked by
dean.carrefour
Top achievements
Rank 1
Answers by
Thad
Top achievements
Rank 2
dean.carrefour
Top achievements
Rank 1
Share this question
or