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

find controle for panel bar

2 Answers 41 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
komathi priya
Top achievements
Rank 1
komathi priya asked on 28 Apr 2010, 05:37 AM
hi,

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.

Regards
Priya

 

2 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 28 Apr 2010, 08:52 AM
Hi Priya,

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

Regards,
Yana
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.
0
Accepted
Matthew
Top achievements
Rank 1
answered on 21 Jul 2010, 06:52 PM
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.
Tags
PanelBar
Asked by
komathi priya
Top achievements
Rank 1
Answers by
Yana
Telerik team
Matthew
Top achievements
Rank 1
Share this question
or