RadComboBox CheckedItems returns 0 when other controls don't have values selected

2 posts, 0 answers
  1. Andy
    Andy avatar
    1 posts
    Member since:
    Aug 2013

    Posted 22 Aug 2013 Link to this post

    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?

  2. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 27 Aug 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top