This is a migrated thread and some comments may be shown as answers.
RadComboBox CheckedItems returns 0 when other controls don't have values selected
1 Answer 31 Views
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 22 Aug 2013, 08:31 AM
Hi, 

I have a user control which has several RadComboBoxes with CheckBoxes set to True.

Some of these combo boxes have cascading datasources and have TextChanged events so when the user changes what items are checked it will re-bind the relevant controls that use this selection.

On the page I have a standard ASP.NET button which gets the values from these combo boxes and updates a chart and table etc.  When this button is clicked it is triggering the TextChanged events of the combo boxes which is making the combo boxes think nothing is selected when you can physically see items checked.

I have four combo boxes, ddlProject, ddlUnit, ddlDiscipline and ddlDocType.  ddlProject binds unit, discipline and doc type and unit/discipline update doc type.  Values don't need to be selected for these for the datasource as if there are no selected items then the SQL statements ignores this in the where clause.

If I don't select anything in unit or discipline there ddlDocType still binds and I can select items but when I click my button the TextChanged events fire and the CheckedItems for ddlDocType is 0.  If I have items selected in unit and discipline CheckItems for ddlDocType gives the correct number.

This is the structure of the combo boxes

<telerik:RadComboBox ID="ddlUnit" runat="server" CheckBoxes="true" EnableCheckAllItemsCheckBox="true"
   MaxHeight="450px" Width="300px" DataTextField="Value" DataValueField="Key" Label="Unit:"
   LabelCssClass="HeaderLabel" DropDownWidth="600px" Height="400px"
   AutoPostBack="true" OnTextChanged="ddlUnit_TextChanged">
</telerik:RadComboBox>

This is an example of the OnTextChanged event

protected void ddlDiscipline_TextChanged(object sender, EventArgs e)
{
    CTRmDataService ctrmDS = new CTRmDataService();
 
    this.ddlDocType.DataSource = ctrmDS.GetDocumentTypesForProjectsDisciplineAndUnit(GetSelectedProjects(),
                                                                                GetSelectedDisciplines(),
                                                                                GetSelectedUnits(),
                                                                                LoggedOnUser.Id);
    this.ddlDocType.DataBind();
}

My user control has methods to make the selected items accessible such as :

public string[] GetSelectedDocTypes()
{
    return ddlDocType.CheckItems.Where(x => x.Value != "PSP")
                       .Select(v => v.Value).ToArray<string>();
}

I've been looking at this for quite a while now trying to figure out why the Telerik control events are being fired when I click the button and why the ddlDocType CheckedItems is bringing back nothing when nothing is selected in Unit/Discipline.

Can anyone help?

1 Answer, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 27 Aug 2013, 08:11 AM
Hello Andy,

I have investigated the issue thoroughly and it seems as a bug. I have forwarded it to our developer team for further investigation. Thank you for pointing that out. Your Telerik Points are updated.

Regards,
Nencho
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.
Asked by
Andy
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Share this question
or