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

Filtering combobox not working with ajax

1 Answer 62 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jill
Top achievements
Rank 1
Jill asked on 29 Nov 2008, 10:37 PM
I have a combobox defined on my .aspx page as follows:

<radC:RadComboBox ID="ddlCustomers" runat="server" Height="300px" EnableLoadOnDemand="true"

HighlightTemplatedItems="true" Skin="WindowsXP" Width="300px" AutoPostBack="true" />


I load the combobox in the ItemRequested event as follows:
With ddlCustomers

 

 

'-- 1) Clear any items that already exist --

 

 

.Items.Clear()

 

 

'-- 2) Set the fields, get the dataset and bind the results --

 

 

.DataTextField = strTextField

 

.DataValueField = strValueField

.DataSource = GetDataTable(chkActiveOnly.checked)

.DataBind()

 

End With

 

 

I have a checkbox on the page that is autopostback and ajaxifies as follows:

 

<asp:CheckBox ID="chkActiveOnly" runat="server" Text="Active Customers Only" AutoPostBack="true" />

 

 

<radA:RadAjaxManager ID="ramManageCustomers" runat="server">

<AjaxSettings>

<radA:AjaxSetting AjaxControlID="chkActiveOnly">

<UpdatedControls>

<radA:AjaxUpdatedControl ControlID="chkActiveOnly" />

<radA:AjaxUpdatedControl ControlID="ddlCustomers" />

</UpdatedControls>

</radA:AjaxSetting>

</AjaxSettings>

</radA:RadAjaxManager>

 

Here is the checkchanged event for my checkbox:

 

Protected

Sub chkActiveOnly_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkActiveOnly.CheckedChanged

 

Response.Cookies.Add(

New HttpCookie("ShowInactive", Not chkActiveOnly.Checked))

 

ddlCustomers.Items.Clear()

 

End Sub

 

 

When I navigate to the page, the stored procedure in the ItemRequested event pulls only records that are marked active in the DB.  If I click the checkbox to uncheck it (meaning I want to populate the combobox with all values and not just those that are marked active in the DB), the combobox fills all values just fine.  However, if I try to filter the combobox by entering a "t" in the textbox area of the combobox so that it only shows records in the combobox that start with a "t", the list reverts back to the original stored procedure used (which filters out inactive records).  I am assuming this is a problem with how the radcombobox ajaxifies, but if you have a work around, that would really help.

1 Answer, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 02 Dec 2008, 04:24 PM
Hello Jill,

This happens because the current state of the CheckBox is unavailable in the ItemsRequested event handler - it is in its initial state - unchecked.

Please use the ClientDataString to send the state of the CheckBox from the client to the server. Please see this help article for more information about the approach.

Kind regards,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
Jill
Top achievements
Rank 1
Answers by
Simon
Telerik team
Share this question
or