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

Items dissapear and other items get copied after postback

2 Answers 41 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
it-workz
Top achievements
Rank 1
it-workz asked on 25 Aug 2011, 04:00 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar Terziev
Telerik team
answered on 30 Aug 2011, 11:05 AM
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 >>

0
it-workz
Top achievements
Rank 1
answered on 30 Aug 2011, 12:08 PM
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.
Tags
ComboBox
Asked by
it-workz
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
it-workz
Top achievements
Rank 1
Share this question
or