find controle for panel bar

3 posts, 1 answers
  1. komathi priya
    komathi priya avatar
    30 posts
    Member since:
    Apr 2010

    Posted 28 Apr 2010 Link to this post


    i used the textbox inside the panelbar i used the following codes the find the controle but the value i'm getting from the textbox is null

    foreach (RadPanelItem PanelItem in RadPanelBar1.GetAllItems())
    RadTextBox txtAge = RadPanelBar1.FindControl("txtAge") as RadTextBox;
    RadTextBox txtWeight = RadPanelBar1.FindControl("txtWeight") as RadTextBox;
    health.Age = Convert.ToInt32(txtAge.Text);
    health.weight = Convert.ToInt32(txtWeight.Text);

    the value of txtAge and txtWeight is always null even if i gave different value in runtime
    how to get the value of the textbox entred in run time.


  2. Yana
    Yana avatar
    5042 posts

    Posted 28 Apr 2010 Link to this post

    Hi Priya,

    You should first find the item which contains the textbox and then use FindControl method as it's demonstrated here.

    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Answer
    Matthew avatar
    20 posts
    Member since:
    Jun 2010

    Posted 21 Jul 2010 Link to this post

    This is a bit of a crosspost from the ASP.NET forum (where I erroneously posted it in the first place)

    Using an item template makes the process in the demos (and the helpfile) a bit hard to follow.
    This is because in the walkthrough for placing controls in an itemtemplate we are required to add a radpanelitem with no text.

    So this code, as recommended in the demo and helpfile:
    Dim txtbox as textbox = DirectCast(RadPanelBarName.FindItemsByValue("RadPanelBarValue").FindControl("ControlID"), textbox)
    will not work

    I have found that it works if you add the reference to the item containing the template first, such as:
    Dim txtbox as textbox = DirectCast(RadPanelBarName.FindItemsByValue("RadPanelBarValue").Items(0).FindControl("ControlID"), textbox)

    Note where I reference "Items(0)" and call its FindControl method.
Back to Top