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

related RadcomboBoxes gets reset after changingselectedIndexes

1 Answer 13 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
shemein
Top achievements
Rank 1
shemein asked on 15 Jul 2014, 05:39 AM
I have two Radcombobox which the first one is binding to a dataTable. when the Item is selected from the first radcombobox according to that the second one Items maybe populated or if not we have to be able to type in it. when I click in the second one to type (for example:5555) the drop down collapses and 5555 is removed and it shows the default text so fast and the user oblige to open it again. I want the Radcombobox doesn't get refresh.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 15 Jul 2014, 10:04 AM
Hi shemein,

Please try the below sample code snippet which works fine at my end. Please provide your code if it doesn't help.

ASPX:
<telerik:RadComboBox ID="rcboFirstList" runat="server" DataSourceID="sqldsOrders" EmptyMessage="select" DataTextField="Id" DataValueField="text" AutoPostBack="true" OnSelectedIndexChanged="rcboFirstList_SelectedIndexChanged">
</telerik:RadComboBox>
<telerik:RadComboBox ID="rcboSecondList" runat="server" AutoPostBack="true" AllowCustomText="true" EmptyMessage="Select">
</telerik:RadComboBox>

C#:
protected void rcboFirstList_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
{
    SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
    SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM ComboSecond WHERE ID=@ID", connection);
    adapter.SelectCommand.Parameters.AddWithValue("@ID", e.Text);
    DataTable dt = new DataTable();
    adapter.Fill(dt);
    if (dt.Rows.Count != 0)
    {
        rcboSecondList.DataTextField = "ID";
        rcboSecondList.DataSource = dt;
        rcboSecondList.DataBind();
    }
}

Thanks,
Shinu.
Tags
ComboBox
Asked by
shemein
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or