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

Activate Panelbars from DropDownList

4 Answers 66 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Kurt Kluth
Top achievements
Rank 1
Kurt Kluth asked on 02 Oct 2013, 09:12 PM
Trying to utilize the RadPanelBar but I need it controlled by a RadDropDownList.  I am unsure of how to do this via the code-behind because there is no "ID" associated with them.  Currently they are set to visible=false but would like to make them visible when a user changes the DropDownList. 

If option 1 then show these RadPanelBar options
If Option 2 then show these RadPanelBar options,
etc...

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Oct 2013, 04:07 AM
Hi Kurt Kluth,

Please have a look into the full code that I tried.

ASPX:
<telerik:RadDropDownList ID="RadDropDownList1" runat="server" AutoPostBack="true"
    OnItemSelected="RadDropDownList1_ItemSelected">
    <Items>
        <telerik:DropDownListItem Text="Mail" />
        <telerik:DropDownListItem Text="Contacts" />
    </Items>
</telerik:RadDropDownList>
<br />
<br />
<telerik:RadPanelBar ID="RadPanelBar1" runat="server" Visible="false">
</telerik:RadPanelBar>

C#:
protected void RadDropDownList1_ItemSelected(object sender, Telerik.Web.UI.DropDownListEventArgs e)
{
    RadPanelBar1.Visible = true;
    RadPanelBar1.Items.Clear();
    RadPanelItem MainItem1 = new RadPanelItem();
    RadPanelItem subitem1 = new RadPanelItem();
    RadPanelItem subitem2 = new RadPanelItem();
    RadPanelItem subitem3 = new RadPanelItem();
    if (RadDropDownList1.SelectedText == "Mail")
    {
        MainItem1.Text = "Mail";
        subitem1.Text = "Inbox";
        subitem2.Text = "SentItems";
        subitem3.Text = "Outbox";
 
        MainItem1.Items.Add(subitem1);
        MainItem1.Items.Add(subitem2);
        MainItem1.Items.Add(subitem3);
 
        RadPanelBar1.Items.Add(MainItem1);
    }
    else
    {
        MainItem1.Text = "Contacts";
        subitem1.Text = "MyContacts";
        subitem2.Text = "PhoneList";
        subitem3.Text = "SharedContacts";
 
        MainItem1.Items.Add(subitem1);
        MainItem1.Items.Add(subitem2);
        MainItem1.Items.Add(subitem3);
 
        RadPanelBar1.Items.Add(MainItem1);
    }
}

Thanks,
Princy.
0
Kurt Kluth
Top achievements
Rank 1
answered on 08 Oct 2013, 01:35 PM
Princy,

I tried following your code example and was able to get it to work as you outlined, however I should have included code with the original post in order to have it make more sense.  I already have everything I want to show setup, it is just a matter of showing them.  So maybe it is just modifying the code-behind slightly to get what I need?  Not sure.  See code below:

By default the 4 main items are shown: Favorites, CU Info, Financial, Ratio
If the dropdown changes to Primary or Excess: I need to add some more items to those already shown

Let me know if this helps...
<table style="width: 100%; border: 1px;">
        <tr>
            <td colspan="2">
            <qsf:InformationBox ID="InformationBox1" runat="server" Width="100%" Title="CU Custom Search">
                The CU Data Bank Custom Search feature allows you to query data from differenty types of credit unions and return specific information that you selected. 
                You will be prompted with a series of screens to help you retrieve the type of date you require.  Once you have finished enter in your criteria, you have the option to save the query
                and view your report on screen or export to PDF or MS Excel.
            </qsf:InformationBox>
            </td>
        </tr>
        <tr><td> </td></tr>
        <tr>
            <td style="vertical-align: top; width: 280px; border: 1px solid black; " rowspan="2">
                <!-- TABS -->
                <telerik:RadTabStrip ID="RadTabStrip1" runat="server" SelectedIndex="0" MultiPageID="RadMultiPage2" Width="100%">
                    <Tabs>
                        <telerik:RadTab ToolTip="Fields" Text="Fields"></telerik:RadTab>
                        <telerik:RadTab ToolTip="Filters" Text="Filters"></telerik:RadTab>
                        <telerik:RadTab ToolTip="Dates" Text="Dates" Enabled="False"></telerik:RadTab>
                        <telerik:RadTab ToolTip="Saved Searches" Text="Save"></telerik:RadTab>
                    </Tabs>
                </telerik:RadTabStrip>
 
                <!-- FIELDS TAB -->
                <telerik:RadMultiPage runat="server" ID="RadMultiPage2" SelectedIndex="0" CssClass="innerMultiPage">
                    <telerik:RadPageView runat="server" ID="vwFields">
                        <telerik:RadPanelBar ID="RadPanelBar1" Runat="server" ExpandMode="FullExpandedItem" Height="700px" Width="280px" Visible="True">
                            <Items>
                                <%--<!-- DEFAULT TABS FOR EITHER FMS OR POLICYHOLDER -->--%>
                                <telerik:RadPanelItem Expanded="true" text="Favorites" Visible="true">
                                    <ContentTemplate>
                                        <telerik:RadTreeView ID="_rtvwFavorites" runat="server" DataSourceID="XmlDataSource4" CheckBoxes="True" CheckChildNodes="True" TriStateCheckBoxes="False"  >
                                                <DataBindings>
                                                    <telerik:RadTreeNodeBinding DataMember="Node" TextField="Text" ExpandedField="Expanded" Checked="True" ValueField="ID"></telerik:RadTreeNodeBinding>
                                                </DataBindings>
                                        </telerik:RadTreeView>
                                        <asp:XmlDataSource ID="XmlDataSource4" runat="server" DataFile="~/Common/FavoritesTree.xml" XPath="/Favorites/Node"></asp:XmlDataSource>
                                    </ContentTemplate>
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="Credit Union" Visible="true">
                                    <ContentTemplate>
                                        <telerik:RadTreeView ID="_rtvwCreditUnion" runat="server" DataSourceID="XmlDataSource3" CheckBoxes="True" CheckChildNodes="True" TriStateCheckBoxes="False"  >
                                                <DataBindings>
                                                    <telerik:RadTreeNodeBinding DataMember="Node" TextField="Text" ExpandedField="Expanded" ValueField="ID"></telerik:RadTreeNodeBinding>
                                                </DataBindings>
                                        </telerik:RadTreeView>
                                        <asp:XmlDataSource ID="XmlDataSource3" runat="server" DataFile="~/Common/CuInfoTree.xml" XPath="/CUInfo/Node"></asp:XmlDataSource>
                                    </ContentTemplate>
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="Financial" Visible="true">
                                    <ContentTemplate>
                                    <telerik:RadTreeView ID="_rtvwFinancialList" Runat="server"
                                                DataSourceID="XmlDataSource1" CheckBoxes="True" CheckChildNodes="True" TriStateCheckBoxes="False"  >
                                                <DataBindings>
                                                    <telerik:RadTreeNodeBinding DataMember="Node" TextField="Text" ExpandedField="Expanded" ValueField="ID"></telerik:RadTreeNodeBinding>
                                                </DataBindings>
                                    </telerik:RadTreeView>
                                    <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/Common/FinancialTree.xml" XPath="/Financial/Node"></asp:XmlDataSource>
                                    </ContentTemplate>
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="Ratio" Visible="True">
                                    <ContentTemplate>
                                    <telerik:RadTreeView ID="_rtvwRatioList" Runat="server"
                                                DataSourceID="_RatioListData" CheckBoxes="True" CheckChildNodes="True" TriStateCheckBoxes="False"  Visible="True">
                                                <DataBindings>
                                                    <telerik:RadTreeNodeBinding DataMember="Node" TextField="Text" ExpandedField="Expanded" ValueField="ID"></telerik:RadTreeNodeBinding>
                                                </DataBindings>
                                    </telerik:RadTreeView>
                                    <asp:XmlDataSource ID="_RatioListData" runat="server" DataFile="~/Common/RatioTree.xml" XPath="/Ratio/Node"></asp:XmlDataSource>
                                    </ContentTemplate>
                                </telerik:RadPanelItem>
                                <%--<!-- END DEFAULT TABS -->
                                <!-- FMS DEFAULT TABS -->--%>
                                <telerik:RadPanelItem Text="Policy" Visible="False">
                                    <ContentTemplate>
                                        <telerik:RadTreeView ID="_rtvwPolicyList" runat="server" DataSourceID="XmlDataSource2" CheckBoxes="True" CheckChildNodes="True" TriStateCheckBoxes="False" Visible="True">
                                                <DataBindings>
                                                    <telerik:RadTreeNodeBinding DataMember="Node" TextField="Text" ExpandedField="Expanded" ValueField="ID"></telerik:RadTreeNodeBinding>
                                                </DataBindings>
                                        </telerik:RadTreeView>
                                        <asp:XmlDataSource ID="XmlDataSource2" runat="server" DataFile="~/Common/PolicyTree.xml" XPath="/Policy/Node"></asp:XmlDataSource>
                                    </ContentTemplate>
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="Kroll" Visible="False">
                                    <ContentTemplate>
                                    <telerik:RadTreeView ID="_rtvwKrollList" Runat="server"
                                                DataSourceID="_KrollListData" CheckBoxes="True" CheckChildNodes="True" TriStateCheckBoxes="False"  Visible="True">
                                                <DataBindings>
                                                    <telerik:RadTreeNodeBinding DataMember="Node" TextField="Text" ExpandedField="Expanded" ValueField="ID"></telerik:RadTreeNodeBinding>
                                                </DataBindings>
                                    </telerik:RadTreeView>
                                    <asp:XmlDataSource ID="_KrollListData" runat="server" DataFile="~/Common/KrollTree.xml" XPath="/Kroll/Node"></asp:XmlDataSource>
                                    </ContentTemplate>
                                </telerik:RadPanelItem>
                                <%--<!-- FMS DEFAULT TABS -->
                                <!-- ONLY SHOW FOR PRIMARY INSURED AND FMS -->--%>
                                <telerik:RadPanelItem Text="Primary Policy" Visible="False">
                                    <ContentTemplate>
                                    <telerik:RadTreeView ID="_rtvwPrimaryList" Runat="server"
                                                DataSourceID="_PrimaryListData" CheckBoxes="True" CheckChildNodes="True" TriStateCheckBoxes="False"  Visible="True">
                                                <DataBindings>
                                                    <telerik:RadTreeNodeBinding DataMember="Node" TextField="Text" ExpandedField="Expanded" ValueField="ID"></telerik:RadTreeNodeBinding>
                                                </DataBindings>
                                    </telerik:RadTreeView>
                                    <asp:XmlDataSource ID="_PrimaryListData" runat="server" DataFile="~/Common/PrimaryPolicyTree.xml" XPath="/PrimaryPolicy/Node"></asp:XmlDataSource>
                                    </ContentTemplate>
                                </telerik:RadPanelItem>
                                <%-- <!-- ONLY SHOW FOR EXCESS INSURED AND FMS --> --%>
                                <telerik:RadPanelItem Text="Excess Policy" Visible="False">
                                    <ContentTemplate>
                                    <telerik:RadTreeView ID="_rtvwExcessList" Runat="server"
                                                DataSourceID="_ExcessListData" CheckBoxes="True" CheckChildNodes="True" TriStateCheckBoxes="False"  Visible="True">
                                                <DataBindings>
                                                    <telerik:RadTreeNodeBinding DataMember="Node" TextField="Text" ExpandedField="Expanded" ValueField="ID"></telerik:RadTreeNodeBinding>
                                                </DataBindings>
                                    </telerik:RadTreeView>
                                    <asp:XmlDataSource ID="_ExcessListData" runat="server" DataFile="~/Common/ExcessPolicyTree.xml" XPath="/ExcessPolicy/Node"></asp:XmlDataSource>
                                    </ContentTemplate>
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="Excess Tracking" Visible="False">
                                    <ContentTemplate>
                                    <telerik:RadTreeView ID="_rtvwExcessTracking" Runat="server"
                                                DataSourceID="_ExcessTrackingListData" CheckBoxes="True" CheckChildNodes="True" TriStateCheckBoxes="False"  Visible="True">
                                                <DataBindings>
                                                    <telerik:RadTreeNodeBinding DataMember="Node" TextField="Text" ExpandedField="Expanded" ValueField="ID"></telerik:RadTreeNodeBinding>
                                                </DataBindings>
                                    </telerik:RadTreeView>
                                    <asp:XmlDataSource ID="_ExcessTrackingListData" runat="server" DataFile="~/Common/ExcessTrackingTree.xml" XPath="/ExcessTracking/Node"></asp:XmlDataSource>
                                    </ContentTemplate>
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="Legacy Endorsements" Visible="False">
                                    <ContentTemplate>
                                    <telerik:RadTreeView ID="_rtvwLegacy" Runat="server"
                                                DataSourceID="_LegacyListData" CheckBoxes="True" CheckChildNodes="True" TriStateCheckBoxes="False"  Visible="True">
                                                <DataBindings>
                                                    <telerik:RadTreeNodeBinding DataMember="Node" TextField="Text" ExpandedField="Expanded" ValueField="ID"></telerik:RadTreeNodeBinding>
                                                </DataBindings>
                                    </telerik:RadTreeView>
                                    <asp:XmlDataSource ID="_LegacyListData" runat="server" DataFile="~/Common/LegacyEndTree.xml" XPath="/LegacyEnd/Node"></asp:XmlDataSource>
                                    </ContentTemplate>
                                </telerik:RadPanelItem>
                                <%-- <!--FOR EITHER PRIMARY OR EXCESS AND FMS --> --%>
                                <telerik:RadPanelItem Text="Audit" Visible="False">
                                    <ContentTemplate>
                                    <telerik:RadTreeView ID="_rtvwAudit" Runat="server"
                                                DataSourceID="_AuditListData" CheckBoxes="True" CheckChildNodes="True" TriStateCheckBoxes="False"  Visible="True">
                                                <DataBindings>
                                                    <telerik:RadTreeNodeBinding DataMember="Node" TextField="Text" ExpandedField="Expanded" ValueField="ID"></telerik:RadTreeNodeBinding>
                                                </DataBindings>
                                    </telerik:RadTreeView>
                                    <asp:XmlDataSource ID="_AuditListData" runat="server" DataFile="~/Common/AuditTree.xml" XPath="/Audit/Node"></asp:XmlDataSource>
                                    </ContentTemplate>
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="Billing" Visible="False">
                                    <ContentTemplate>
                                    <telerik:RadTreeView ID="_rtvwBilling" Runat="server"
                                                DataSourceID="_BillingListData" CheckBoxes="True" CheckChildNodes="True" TriStateCheckBoxes="False"  Visible="True">
                                                <DataBindings>
                                                    <telerik:RadTreeNodeBinding DataMember="Node" TextField="Text" ExpandedField="Expanded" ValueField="ID"></telerik:RadTreeNodeBinding>
                                                </DataBindings>
                                    </telerik:RadTreeView>
                                    <asp:XmlDataSource ID="_BillingListData" runat="server" DataFile="~/Common/BillingTree.xml" XPath="/Billing/Node"></asp:XmlDataSource>
                                    </ContentTemplate>
                                </telerik:RadPanelItem>
                            </Items>
                        </telerik:RadPanelBar>
                    </telerik:RadPageView>
                    <!--Filters Tab -->
                    <telerik:RadPageView runat="server" ID="vwFilters" Width="280px" Height="700px">
                        <table>
                            <tr>
                                <td><b>State(s):</b><br />
                                    <telerik:RadListBox ID="_cboStates" runat="server" Height="75px"
                                        SelectionMode="Multiple" Width="225px">
                                    </telerik:RadListBox>
                                    <br /><br />
                                    <b>
                                        <asp:Label ID="_lblSponsor" runat="server" Text="ASI Sponsor:"></asp:Label></b><br />
                                    <telerik:RadListBox ID="_cboSponsor" runat="server" Height="75px"
                                        SelectionMode="Single" Width="225px" Visible="false">
                                    </telerik:RadListBox>
                                </td>
                            </tr>
                        </table>
                    </telerik:RadPageView>
                    <telerik:RadPageView runat="server" ID="vwDates" Width="280px" Height="700px">
                        <table>
                            <tr><td colspan="2">Financial Dates<br />
                                Due to your selection of information from the Financial Categories, a Financial date is required.
                                Note: You must select at least one (1) date but can select up to three (3) dates.
                                Any criteria entered in the Filters tab, will return data based on the first Financial Date selected,
                                additional dates selected will be only for historical purposes only.</td></tr>
                            <tr>
                                <td>Dates:</td>
                                <td>
                                    <telerik:RadDropDownList ID="_cboMonth" runat="server" Width="95px"
                                        DefaultMessage="Select Month">
                                        <Items>
                                            <telerik:DropDownListItem Value="1" Text="January" />
                                            <telerik:DropDownListItem Value="2" Text="February" />
                                            <telerik:DropDownListItem Value="3" Text="March" />
                                            <telerik:DropDownListItem Value="4" Text="April" />
                                            <telerik:DropDownListItem Value="5" Text="May" />
                                            <telerik:DropDownListItem Value="6" Text="June" />
                                            <telerik:DropDownListItem Value="7" Text="July" />
                                            <telerik:DropDownListItem Value="8" Text="August" />
                                            <telerik:DropDownListItem Value="9" Text="September" />
                                            <telerik:DropDownListItem Value="10" Text="October" />
                                            <telerik:DropDownListItem Value="11" Text="November" />
                                            <telerik:DropDownListItem Value="12" Text="December" />
                                        </Items>
                                    </telerik:RadDropDownList>
                                    <telerik:RadDropDownList ID="_cboYear" runat="server" Width="85px" DefaultMessage="Select Year">
                                    </telerik:RadDropDownList>
                                </td>
                            </tr>
                        </table>
                    </telerik:RadPageView>
                    <telerik:RadPageView  runat="server" ID="vwSave" Width="280px" Height="700px">
                        <table>
                            <tr><td>If you would like to save this search, enter a name to identify the search and click the "View Search" button below.</td></tr>
                            <tr>
                                <td>
                                    <telerik:RadTextBox runat="server" ID="_txtSaveName" EmptyMessage="Enter a name to save"></telerik:RadTextBox>
                                    <telerik:RadButton ID="_btnSaveSearch" runat="server" Text="Save"></telerik:RadButton>                   
                            </td></tr>
                            <tr><td><b>List of Saved Searches:</b></td></tr>
                        </table>
                    </telerik:RadPageView>
                </telerik:RadMultiPage>
 
                <br />                               
                <telerik:RadButton ID="_btnUpdateResults" runat="server" Text="Update Results"></telerik:RadButton>
                <telerik:RadButton ID="_btnResetResults" runat="server" Text="Reset Search Results"></telerik:RadButton>
                <br />
            </td>
            <td style="vertical-align: top; border: 1px solid black; height: 50px;" >
                <b>Select the type of credit union group you wish to sample data from: </b>
                            <telerik:RadComboBox ID="_CUType" runat="server" AutoPostBack="True"
                    Width="300px">
                    <Items>
                        <telerik:RadComboBoxItem runat="server" Text="All Credit Unions Nationally"
                            Value="allcreditunions" />
                        <telerik:RadComboBoxItem runat="server" Text="All State Chartered CU's"
                            Value="statechartered" />
                        <telerik:RadComboBoxItem runat="server" Text="All Federally Chartered CU's"
                            Value="federalchartered" />
                        <telerik:RadComboBoxItem runat="server" Text="All ASI/ESI Members"
                            Value="allmembers" />
                        <telerik:RadComboBoxItem runat="server" Text="Primary Members"
                            Value="primary" />
                        <telerik:RadComboBoxItem runat="server" Text="Excess Members" Value="excess" />
                    </Items>
                </telerik:RadComboBox><br />
                <label for="RadioButtonList1">Show filtering item</label>
                <asp:RadioButtonList runat="server" ID="RadioButtonList1" RepeatDirection="Horizontal">
                    <asp:ListItem Text="Yes" Selected="True" onclick="showFilterItem()"></asp:ListItem>
                    <asp:ListItem Text="No" onclick="hideFilterItem()"></asp:ListItem>
                </asp:RadioButtonList>
            </td>
         </tr>
 
    </table>
</telerik:RadAjaxPanel>






0
Accepted
Boyan Dimitrov
Telerik team
answered on 11 Oct 2013, 12:20 PM
Hello,

In the code snippet below you may find an approach showing a specific RadPanelBar item with text "Policy" when an RadDropDownList item with text "Primary" is selected.
//code behind
protected void RadDropDownList1_ItemSelected(object sender, Telerik.Web.UI.DropDownListEventArgs e)
    {
        if (e.Text == "Primary")
        {
            RadPanelBar1.FindItemByText("Policy").Visible = true;
        }
         
    }

Hope that this will be helpful.

Regards,
Boyan Dimitrov
Telerik
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 the blog feed now.
0
Kurt Kluth
Top achievements
Rank 1
answered on 16 Oct 2013, 03:37 PM
Boyan

Thank you for your help.  That worked perfectly. 
Tags
PanelBar
Asked by
Kurt Kluth
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Kurt Kluth
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or