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

Radpanel with Radcombobox

1 Answer 39 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Mani PC
Top achievements
Rank 1
Mani PC asked on 01 Apr 2013, 03:20 PM
Hello,

i have Radpanelbar with mutiple comboboxes(Combo1, Combo2, Combo3...) in each panel.....

I want to populate items in Combo2 based on Comb1 selection....

i want to do from code behind....

how to get SelectedIndexedChanged event of Combo1 or Click event of Combo2 from codebehind....

Here is my markup...

<telerik:RadPanelBar runat="server" ID="rpbReconciliationSummaryInquiry" Height="300"
            Font-Bold="True" Font-Size="Large" ExpandMode="SingleExpandedItem"  OnClientItemExpand="OnClientItemExpand"
              Width="300" >
            <Items>
                       
                <telerik:RadPanelItem Expanded="False" Text="Dept / Class / Vendor / Location"  Value="DCVLTop" Font-Bold="True"   ForeColor="White">
                    <Items>
                        <telerik:RadPanelItem Value="DCVL"   Text="">       
                           <ItemTemplate>     
                            <table>

                                     <tr>
                                            <td>
                                                <asp:Label ID="lblDept" runat="server" Text="Dept:" CssClass="label" />
                                            </td>
                                               <td>
                                                  <telerik:RadComboBox ID="cmbDeptDCVL" runat="server"     OnClientBlur="OnClientBlurHandler"
                                                                AllowCustomText="false" EnableLoadOnDemand="true" MarkFirstMatch="true" Width="100"
                                                                TabIndex="6"  DropDownWidth="350px" AutoPostBack="True" >
                                                                 <HeaderTemplate>
                                                            <table>
                                                                <tr>                                                                 
                                                                    <td width="80"> Dept </td>
                                                                    <td width="220">Description </td>
                                                                </tr>
                                                            </table>
                                                        </HeaderTemplate>
                                                        <ItemTemplate>
                                                            <table>
                                                                <tr align="left">
                                                                  <td width="20">
                                                                        <asp:CheckBox runat="server" ID="chkSingleDeptDCVL"    Text=""  />
                                                                    </td>
                                                                    <td width="80" align="left"> <%#CType(Container.DataItem, PhysicalInventory.Models.ApplCompStructInfo).DeptId%> </td>
                                                                    <td width="220" align="left"> <%#CType(Container.DataItem, PhysicalInventory.Models.ApplCompStructInfo).DeptShortDesc%> </td>
                                                                </tr>
                                                            </table>
                                                        </ItemTemplate>
                                            <CollapseAnimation Duration="200" Type="OutQuint" />
                                        </telerik:RadComboBox>
                                    </td>
                                </tr>

                                   <tr>
                                    <td>
                                        <asp:Label ID="lblClass" runat="server" Text="Class:" CssClass="label" />
                                    </td>
                                       <td>
                                          <telerik:RadComboBox ID="cmbClassDCVL" runat="server" OnClientBlur="OnClientBlurHandler"
                                            AllowCustomText="false" EnableLoadOnDemand="true" MarkFirstMatch="true" Width="100"
                                            TabIndex="6"  DropDownWidth="350px">
                                                      <HeaderTemplate>
                                                            <table>
                                                                <tr>
                                                                    <td width="80"> Class </td>
                                                                    <td width="250">Description </td>
                                                                </tr>
                                                            </table>
                                                        </HeaderTemplate>
                                                        <ItemTemplate>
                                                            <table>
                                                                <tr align="left">
                                                                   <td width="20">
                                                                        <asp:CheckBox runat="server" ID="chkSingleClassDCVL"    Text=""    />
                                                                    </td>
                                                                    <td width="80" align="left"> <%#CType(Container.DataItem, PhysicalInventory.Models.ApplDptClsInfo).ClassId%> </td>
                                                                    <td width="250" align="left">  <%#CType(Container.DataItem, PhysicalInventory.Models.ApplDptClsInfo).ClassShortDesc%></td>
                                                                </tr>
                                                            </table>
                                                        </ItemTemplate>
                                            <CollapseAnimation Duration="200" Type="OutQuint" />
                                        </telerik:RadComboBox>
                                    </td>
                                </tr>




1 Answer, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 04 Apr 2013, 12:56 PM
Hello Mani,

You could simply hook the OnSelectedIndexChanged event of the first RadComboBox, as demonstrated in this help article. In addition, note that the AutoPostBack property should be set to true, in order the event to be fired. In the event handler of the OnSelectedIndexChanged event, you could find the RadComboBox, which is needed to be populated and add the Items, regarding the selection of the first RadComboBox. Please consider the following implementation of the event-handler:

protected void cmbDeptDCVL_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
   {
       if (e.Text == "item2")
       {
           RadComboBox comboBox = (RadComboBox)rpbReconciliationSummaryInquiry.FindItemByValue("DCVL").FindControl("cmbClassDCVL");
 
           comboBox.Items.Add(new RadComboBoxItem("RadComboBoxItem 1"));
           comboBox.Items.Add(new RadComboBoxItem("RadComboBoxItem 2"));
           comboBox.Items.Add(new RadComboBoxItem("RadComboBoxItem 3"));
           comboBox.Items.Add(new RadComboBoxItem("RadComboBoxItem 4"));
           comboBox.Items.Add(new RadComboBoxItem("RadComboBoxItem 5"));
       }
   }
 
In addition, here is a video demonstrating the behavior at my end.

Note : I noticed, that you have set the AllowCustomText property of the RadComboBox to false, where you had implemented a Load On Demand functionality. This would not be applied, since the aforementioned property is automatically set to true, once the Load On Demand mechanism is enable. This is described in our help article here.

Regards,
Nencho
the Telerik team
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 their blog feed now.
Tags
ComboBox
Asked by
Mani PC
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Share this question
or