Items dissapear and other items get copied after postback

3 posts, 1 answers
  1. it-workz
    it-workz avatar
    22 posts
    Member since:
    Mar 2007

    Posted 25 Aug 2011 Link to this post

    Hi,

    Im running in some very strange behavior with the  radcombobox (Telerik 2011Q2).
    I have 2 dropdownlist and a button. Changing the selecting of the 1st box alters the content in the 2nd box. the button does nothing special, just a postback.

    When i change the selection of the first box, the 2nd box gets filled correctly. But when i push the button, the contents of the 2nd box gets alterd, the fist 2 items dissapear and the last 2 get copied and are added to the back.

    aspx
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadComboBox ID="ddlbInstituut" runat="server"  AutoPostBack="true" />
    <telerik:RadComboBox ID="ddlbAfdeling" runat="server" CheckBoxes="true" Width="300px"
         />
    <asp:Button ID="Button1" runat="server" Text="Button" />

    vb.net
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Page.IsPostBack = False Then
            vulInstituutDropdown()
        End If
    End Sub
    Sub vulInstituutDropdown()
        Dim dsInstituten As DataSet
        dsInstituten = SqlHelper.ExecuteDataset(Conn, "SP_GetInstituut")
        With ddlbInstituut
            .DataSource = dsInstituten
            .AutoPostBack = True
            .ID = "ddlbInstituut"
            .DataTextField = "inst_omschrijving"
            .DataValueField = "inst_id"
            .DataBind()
        End With
        vulAfdelingDropdown()
    End Sub
    Private Sub vulAfdelingDropdown()
        Dim dsAfdelingen As DataSet
        dsAfdelingen = SqlHelper.ExecuteDataset(Conn, "SP_GetAfdelingen", ddlbInstituut.SelectedValue)
        With ddlbAfdeling
            .Controls.Clear()
            .ID = "ddlbAfdeling"
            .DataSource = dsAfdelingen
            .DataTextField = "afde_omschrijving"
            .DataValueField = "afde_id"
            .DataBind()
        End With
    End Sub
    Protected Sub ddlbInstituut_SelectedIndexChanged1(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlbInstituut.SelectedIndexChanged
        vulAfdelingDropdown()
    End Sub

    The storedprocedures always cough up the correct data.

    When useing radListBox, same problem, enabeling or disabeling the checkboxes makes no difference, when useing conventional dropdownlists, no problems whatsoever.

    Please help.
  2. Answer
    Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1268 posts

    Posted 30 Aug 2011 Link to this post

    Hi It-Workz,

    Please try to clear the items of the second combobox before you bind it with another data. This could be done with the Clear method of the items collection property.

    In case this suggestion is not helping, open a support ticket and provide a sample page with the issue being reproduced.

    Regards,
    Dimitar Terziev
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. it-workz
    it-workz avatar
    22 posts
    Member since:
    Mar 2007

    Posted 30 Aug 2011 Link to this post

    Hi,

    I did use the clear() method, but the wrong one:
    dlbAfdeling.Controls.Clear()  instead of ddlbAfdeling.Items.Clear()

    useing the right one solved it

    My bad, thanks for the help.
Back to Top