Add textbox to panel level through code behind

3 posts, 0 answers
  1. Jeff
    Jeff avatar
    36 posts
    Member since:
    Jan 2008

    Posted 08 Jan 2009 Link to this post

    We have a 3 level radpanel that is built dynamically from a database. At the third level of the radpanel hierarchy we need to add a textbox that we can populate and retrieve data from.

    So for example:

    Employee Salaries
    -- Managers
    ------ John [ textbox ]
    ------ Mary [ textbox ]
    -- Executives
    ------ Harry [textbox ]
    Building Costs
    -- Building 1
    ------ Heat [ textbox ]


    Is there a way to do this?

  2. Paul
    Paul avatar
    4281 posts

    Posted 10 Jan 2009 Link to this post

    Hello Jeff,

    Please find below a sample code snippet that shows the needed approach.

    <html xmlns=""
    <head runat="server"
        <title>Untitled Page</title> 
        <style type="text/css"
            padding-left: 20px !important; 
        <form id="form1" runat="server"
            <asp:ScriptManager ID="ScriptManager1" runat="server"
            <telerik:RadPanelBar ID="RadPanelBar1" runat="server" DataSourceID="SqlDataSource1" DataFieldID="id" DataFieldParentID="parentId" DataTextField="Text" OnItemDataBound="RadPanelBar1_ItemDataBound"
                <CollapseAnimation Duration="100" Type="None" /> 
                <ExpandAnimation Duration="100" Type="None" /> 
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [Links]"></asp:SqlDataSource> 

    using System; 
    using System.Data; 
    using System.Configuration; 
    using System.Collections; 
    using System.Web; 
    using System.Web.Security; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using System.Web.UI.WebControls.WebParts; 
    using System.Web.UI.HtmlControls; 
    public partial class _Default : System.Web.UI.Page 
        protected void Page_Load(object sender, EventArgs e) 
        protected void RadPanelBar1_ItemDataBound(object sender, Telerik.Web.UI.RadPanelBarEventArgs e) 
            if (e.Item.Level == 2) 
                Label lb = new Label(); 
                lb.Text = e.Item.Text; 
                TextBox tb = new TextBox(); 
                tb.Text = e.Item.Text; 
                tb.Width = Unit.Pixel(50); 
                e.Item.Text = ""

    All the best,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. DevCraft R3 2016 release webinar banner
  4. Jeff
    Jeff avatar
    36 posts
    Member since:
    Jan 2008

    Posted 11 Jan 2009 Link to this post

    Thanks for the code sample - worked great!
Back to Top