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

RadComboBox not triggering update of another RadComboBox

5 Answers 206 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Tom Lynch
Top achievements
Rank 1
Tom Lynch asked on 10 Oct 2013, 04:05 PM
Hello,

I have an application with several pages that contain RadComboBoxes.  When I select an option in the first RadComboBox it triggers the other RadComboBoxes to load options based on that selection.  Or rather, it used to do this.  This application has been working this way for years after having been developed in Visual Studio 2008 targeting the 3.5 .NET framework.  Recently, I tried upgrading this application to the 4.0 .NET framework so I could develop in Visual Studio 2010.  Now the RadComboBoxes will not be updated properly when the 1st one's selected option is changed.

Here is the first combobox:
<telerik:radcombobox id="ebaCountry" runat="server" DataTextField="Text" DataValueField="Value" MarkFirstMatch="True" AllowCustomText="False" OnClientSelectedIndexChanging="LoadCountryDependentCombos" OnItemsRequested="ebaCountry_ItemsRequested" OnClientSelectedIndexChanged="EbaChangeCountry" OnClientBlur="EbaChangeCountry" OnClientLoad="SetCountryClientId"></telerik:radcombobox>

The important attribute here is OnClientSelectedIndexChanging.  It triggers javascript code that should cause other RadComboBoxes to be populated with data.  The javascript looks like this:
var item = eventArqs.get_item();
ebaParticipant.set_text(" Loading...");
ebaParticipant.requestItems(item.get_value(), false);

Here is what the second combobox looks like:
<telerik:RadComboBox runat="server" ID="ebaParticipant" MarkFirstMatch="true" DataSourceID="objdsParticipant" OnClientItemsRequested="ItemsLoaded" AllowCustomText="False" OnClientSelectedIndexChanged="EbaChangeParticipant" OnClientBlur="EbaChangeParticipant" OnItemDataBound="ebaParticipant_ItemDataBound" OnClientLoad="SetParticipantClientId" OnItemsRequested="ebaParticipant_ItemsRequested">
                        <ItemTemplate>
                            <ul>
                                <li style="float: left; width: 110px; margin: 0; padding: 0 5px 0 0; line-height: 14px">
                                    <%# DataBinder.Eval(Container.DataItem, "PersonName") %></li>
                                <li style="float: left; width: 110px; margin: 0; padding: 0 5px 0 0; line-height: 14px">
                                    <%# DataBinder.Eval(Container.DataItem, "MinistryName") %></li>
                            </ul>
                        </ItemTemplate>
</telerik:RadComboBox>

The function in the code-behind, ebaParticipant_ItemsRequested, triggered by the OnItemsRequested event sets up a couple of parameters for ObjectDataSource used by the RadComboBox then calls "ebaParticipant.DataBind()" to fill this second combobox with data based on the selected option in the first combobox. 

While debugging in VS2010 I can step through the code and see that the SelectMethod defined for the ObjectDataSource is being called and I can see the data returned from its database query.  The correct data is being returned.  And here is where something breaks down.  For some reason the second combobox on the web page is no longer being filled with the returned data.  Can anyone suggest a way to debug this step in the process?  Any ideas what's going wrong?  Does it have something to do with the change from .NET 3.5 to 4.0?  I'm using version 2011.1.519.35 of Telerik.Web.UI.dll.

-- Tom 
 

5 Answers, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 15 Oct 2013, 11:49 AM
Hi Tom,

What is your browser, does this work on other browsers? Please paste the code from the ebaParticipant_ItemsRequested and the ebaParticipant_ItemDataBound events. Also check whether there are any JavaScript errors on the page.

Regards,
Hristo Valyavicharski
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Tom Lynch
Top achievements
Rank 1
answered on 17 Oct 2013, 04:00 PM
Hello, I'm using IE 9.  Firefox isn't cooperating with my Visual Studio at the moment, so I haven't been able to test with that browser.  I don't see any javascript errors being reported by IE.  The code for my events are as follows:

protected
void ebaParticipant_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
{
            objdsParticipant.SelectParameters[0].Name = "countryId";
            objdsParticipant.SelectParameters[0].Type = TypeCode.Object;
            objdsParticipant.SelectParameters[0].DefaultValue = e.Text;
  
            objdsParticipant.SelectParameters[1].Name = "search";
            objdsParticipant.SelectParameters[1].Type = TypeCode.String;
            objdsParticipant.SelectParameters[1].DefaultValue = string.Empty;
  
            ebaParticipant.DataBind();
}

protected void ebaParticipant_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
{
            e.Item.Text = ((Person)e.Item.DataItem).PersonName;
            e.Item.Value = ((Person)e.Item.DataItem).PersonId.ToString();
}
0
Hristo Valyavicharski
Telerik team
answered on 22 Oct 2013, 02:13 PM
Hi Tom,

OnItemsRequested event will be fired only if the EnableLoadOnDemand property is set to true. Please try to enable it for the ebaParticipant combo. Also try to debug theebaParticipant_ItemsRequested event.
What is the items count of the combo after call ebaParticipant.DataBind() and what data has the objdsParticipant datasource?

protected void ebaParticipant_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
{
    objdsParticipant.SelectParameters[0].Name = "countryId";
    objdsParticipant.SelectParameters[0].Type = TypeCode.Object;
    objdsParticipant.SelectParameters[0].DefaultValue = e.Text;
 
    objdsParticipant.SelectParameters[1].Name = "search";
    objdsParticipant.SelectParameters[1].Type = TypeCode.String;
    objdsParticipant.SelectParameters[1].DefaultValue = string.Empty;
 
    ebaParticipant.DataBind();
}


Regards,
Hristo Valyavicharski
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Tom Lynch
Top achievements
Rank 1
answered on 22 Oct 2013, 03:18 PM
Hello,

I set EnableLoadOnDemand to true.  When debugging it reaches ebaParticipant_ItemsRequested.  After the databind line, the comboxbox has an item count of 407.  This is the expected number of items I should see.  The "ebaParticipant" combobox's datasourceId is set to objdsParticipant. 

So everything looks good up to this point, right?  I'm getting the 407 items.  They are bound to the combobox.  However, the user interface never receives the data.  The ebaParticipant combobox is still unchanged, with no items loaded into it. 

Tom
0
Hristo Valyavicharski
Telerik team
answered on 25 Oct 2013, 02:18 PM
Hi Tom,

The UI of the combo should be updated, after you call DataBind() method. If it is not then the problem must be somewhere else. Please use FiddlerCap to capture the web traffic of the combo, so we can track what calls it makes and check whether the items are returned back to the client.

The best would be if you can attach a sample project, which reproduces the problem. If it exceed the maximum allowed file size, please upload it somewhere(Dropbox, Skydrive, Google Docs) and paste the link here, so I can download it

Regards,
Hristo Valyavicharski
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
ComboBox
Asked by
Tom Lynch
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Tom Lynch
Top achievements
Rank 1
Share this question
or