Adding Control to RadPanel at Runtime

2 posts, 0 answers
  1. Savidu
    Savidu avatar
    3 posts
    Member since:
    Mar 2012

    Posted 20 Jul 2012 Link to this post


    I have create a rad panel as below and for the RadPanelBar with the ID "rpbIncludeSections" items are added dynamically.
    <telerik:RadPanelBar runat="server" ID="rpbResumeSections" Width="300px" GridLines="Horizontal" >
                <telerik:RadPanelItem ID="rpiResumeSections" runat="server" PreventCollapse="false" Expanded="true" >
                        <telerik:RadPanelItem ID="rpbResumeSectionInfo" runat="server" >
                                <div style="margin: 10px;">
                                    <telerik:RadComboBox runat="server" ID="rcbTemplates" Width="250px" AutoPostBack="true"  OnSelectedIndexChanged="rcbTemplates_OnSelectedIndexChanged"></telerik:RadComboBox>
                                <!--Dynamically generate a rad panel bar -->
                                <div style="margin: 10px;max-height: 200px; overflow:auto;">
                                    <telerik:RadPanelBar runat="server" ID="rpbIncludeSections" GridLines="Horizontal" ExpandMode="MultipleExpandedItems" >
                                <div style="margin:10px;margin-top: 30px; text-align:right;">
                                    <telerik:RadButton  ID="btnPreview" runat="server" OnClick="btnPreview_OnClick"></telerik:RadButton>
                                    <telerik:RadButton ID="btnSavePublish" runat="server" OnClick="btnSavePublish_OnClick"></telerik:RadButton>
                                    <telerik:RadButton ID="btnPrintCV" runat="server" OnClick="btnPrintCV_OnClick"></telerik:RadButton>                                         

    The components added dynimacally is as follows
    RadPanelBar _rpbIncludeSections = (RadPanelBar)rpbResumeSectionInfo.FindControl("rpbIncludeSections");
                if (_personID != 0)
                    DataSet _Sections = _cvController.GetSectionsFromCVTemplateIDPersonID(int.Parse(e.Value), _personID);
                    foreach (DataRow _drSection in _Sections.Tables[0].Rows)
                        bool _checked = false;
                        if ((_drSection["Include"].ToString() != "" && bool.Parse(_drSection["Include"].ToString()) == true) || _drSection["Persons_PersonID"].ToString() == "")
                            _checked = true;
                        RadPanelItem _panelItemLvl1 = new RadPanelItem();
                        _panelItemLvl1.Text = _drSection["CV_Section"].ToString();
                        _panelItemLvl1.Selected = true;
                        RadPanelItem _panelItemLvl2 = new RadPanelItem();
                        CheckBox _checkBox = new CheckBox();
                        _checkBox.ID = "Savidu";
                        _checkBox.Checked = _checked;
                        _checkBox.Text = Localization.GetString("Include.Text", this.LocalResourceFile);
                        _checkBox.ToolTip = "Check to Include in ude in CV";
                        _checkBox.CssClass = "MarginLeft";

    This part works fine the issue comes when the button "btnSavePublish" OnClick method i need to find out whether the check box is checked or not.

    For this id some thing like
    RadPanelBar _rpbIncludeSections = (RadPanelBar)rpbResumeSectionInfo.FindControl("rpbIncludeSections");

    Through the Items attribute i am able to find the added panels. I.e since i have added 2 panels i would be able to access them


    But, there is no way for me to access the added checkbox. I tried with the "Controls" attribute as well but it gave no luck.

    Thanks Regards,

  2. Peter
    Peter avatar
    6637 posts

    Posted 24 Jul 2012 Link to this post

    Hi Savidu,

    There is a help topic on Accessing Controls Inside Templates. I hope you find it helpful.

    If you continue to experience problems, please open a support ticket and send us a working sample of the issue.

    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.
Back to Top