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

RadComboBox - SelectedIndexChanged not firing

1 Answer 158 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brad
Top achievements
Rank 1
Brad asked on 05 Oct 2011, 06:08 AM

My first crack at using the RadCombo box and I have a snag.

I  can't get the SelectedIndexChanged event to fire.


Here is some code. My RadComboBox looks like this

<telerik:RadComboBox
    ID="radCustomSearchDropdown" runat="server" Height="200px" Width="200px" DropDownWidth="298px"
    EmptyMessage="Custom Search"
    HighlightTemplatedItems="true"
    EnableLoadOnDemand="true"
    Filter="StartsWith"
    OnSelectedIndexChanged="radCustomSearchDropdown_SelectedIndexChanged"
    AutoPostBack="true">
    
    <ItemTemplate>
        <table style="width: 275px" cellspacing="0" cellpadding="0">
            <tr>
                <td style="width: 260px;">
                    <strong><%# DataBinder.Eval(Container, "Attributes['Title']")%></strong>
                </td>
            </tr>
            <tr>   
                <td style="width: 260px;">
                    <i><%# DataBinder.Eval(Container, "Attributes['Description']")%></i>
                </td>
            </tr>
        </table>
    </ItemTemplate>
</telerik:RadComboBox>

And in the code behind the SelectedIndexChanged code looks like this.

protected void radCustomSearchDropdown_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
{
    int CustomSearchID = Convert.ToInt32(e.Value);
    SetLocationSearchByCustomSearchID(CustomSearchID);
}

This code never gets called.
 
Autopostback is true, the event is defined, what more is there?

1 Answer, 1 is accepted

Sort by
0
Brad
Top achievements
Rank 1
answered on 05 Oct 2011, 06:26 AM
I solved this.

I was not setting the Text or Value property of the RadComboItem as I constructed the contents of the RadComboBox.

I was doing this..

r.Attributes.Add("Title", dr["cls_Title"].ToString());
r.Attributes.Add("Description", dr["cls_Description"].ToString());
r.Attributes.Add("CustomSearchID", dr["cls_Custom_Location_Search_ID"].ToString());
radCustomSearchDropdown.Items.Add(r);

But needed to do this.
r.Text = dr["cls_Title"].ToString();
r.Value = dr["cls_Custom_Location_Search_ID"].ToString();
r.Attributes.Add("Description", dr["cls_Description"].ToString());
radCustomSearchDropdown.Items.Add(r);

This whole thread can be deleted by an admin unless you think it might be of value to someone in the future.

Tags
General Discussions
Asked by
Brad
Top achievements
Rank 1
Answers by
Brad
Top achievements
Rank 1
Share this question
or