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

Check/Uncheck RadComboBox items

5 Answers 1353 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Venkatesh
Top achievements
Rank 1
Venkatesh asked on 24 Aug 2016, 12:16 PM

I have a ASP Dropdown list and Telerik RadComboBox. Both are binding same values.

Now I want to select same value in RadComboBox which user select in ASP Dropdown list.

I have used below codes but RadComboBox always shows previous selcted value only.

5 Answers, 1 is accepted

Sort by
0
Venkatesh
Top achievements
Rank 1
answered on 24 Aug 2016, 12:41 PM

1. protected void ddlList_SelectedIndexChanged(object sender, EventArgs e)
     {
          string Name = ddlList.SelectedItem.Text;
        rcbComboBox.ClearCheckedItems();
         rcbComboBox.Text = string.Empty;
         rcbComboBox.Text = Name;
         rcbComboBox.Items.FindItemByText(Name).Checked = true;
        rcbComboBox.Items.FindItemByText(Name).Selected = true;
     }

 

2. protected void ddlList_SelectedIndexChanged(object sender, EventArgs e)
     {

        rcbComboBox.Text = string.Empty;
rcbComboBox.Text = Name;
foreach (RadComboBoxItem rcbItem in rcbComboBox.Items)
{
   if (rcbItem.Text == Name)
   {
       rcbItem.Checked = true;
   }
   else
   {
       rcbItem.Checked = false;
   }
}

     }

 

ComboBox:

<telerik:RadComboBox ID="rcbComboBox" runat="server" CheckBoxes="true" OnItemChecked="rcbComboBox_ItemChecked" AutoPostBack="true"
                    EmptyMessage="Qualifier Filter" DataTextField="OWNER_TYPE" OnItemDataBound="OnItemDataBound" AllowCustomText="true" >
                </telerik:RadComboBox>

 

DropDownList:

<asp:DropDownList ID="ddlList" OnSelectedIndexChanged="ddlList_SelectedIndexChanged" AutoPostBack="true" DataTextField="OWNER_TYPE" DataValueField="OWNER_TYPE" runat="server" Width="70px">
</asp:DropDownList>

0
Venkatesh
Top achievements
Rank 1
answered on 24 Aug 2016, 12:42 PM

1. protected void ddlList_SelectedIndexChanged(object sender, EventArgs e)
     {
          string Name = ddlList.SelectedItem.Text;
        rcbComboBox.ClearCheckedItems();
         rcbComboBox.Text = string.Empty;
         rcbComboBox.Text = Name;
         rcbComboBox.Items.FindItemByText(Name).Checked = true;
        rcbComboBox.Items.FindItemByText(Name).Selected = true;
     }

 

2. protected void ddlList_SelectedIndexChanged(object sender, EventArgs e)
     {

        rcbComboBox.Text = string.Empty;
rcbComboBox.Text = Name;
foreach (RadComboBoxItem rcbItem in rcbComboBox.Items)
{
   if (rcbItem.Text == Name)
   {
       rcbItem.Checked = true;
   }
   else
   {
       rcbItem.Checked = false;
   }
}

     }

 

ComboBox:

<telerik:RadComboBox ID="rcbComboBox" runat="server" CheckBoxes="true" OnItemChecked="rcbComboBox_ItemChecked" AutoPostBack="true"
                    EmptyMessage="Qualifier Filter" DataTextField="OWNER_TYPE" OnItemDataBound="OnItemDataBound" AllowCustomText="true" >
                </telerik:RadComboBox>

 

DropDownList:

<asp:DropDownList ID="ddlList" OnSelectedIndexChanged="ddlList_SelectedIndexChanged" AutoPostBack="true" DataTextField="OWNER_TYPE" DataValueField="OWNER_TYPE" runat="server" Width="70px">
</asp:DropDownList>

0
Ivan Danchev
Telerik team
answered on 26 Aug 2016, 01:41 PM
Hello Venkatesh,

At my end your code works correctly: after selecting an item in the asp:DropDownList the item with the same Text in the ComboBox is checked. Here's a short video that demonstrates this.
I attached a sample runnable page, in which I tested your code. Note also that if CheckBox support is enabled the ComboBox items' Checked property has to be used instead of Selected. 

Regards,
Ivan Danchev
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
YAMA
Top achievements
Rank 1
answered on 16 Aug 2017, 06:46 AM
Solution 2 worked for me. Thank you
0
YAMA
Top achievements
Rank 1
answered on 16 Aug 2017, 06:47 AM
Solution 2 worked for me. Thank you
Tags
ComboBox
Asked by
Venkatesh
Top achievements
Rank 1
Answers by
Venkatesh
Top achievements
Rank 1
Ivan Danchev
Telerik team
YAMA
Top achievements
Rank 1
Share this question
or