Accessing child controls of a nested repeater control

C

Charlie@CBFC

Hi:

I'm laying out a hieraracical report by nesting repeater controls. I'm
using panels to expand/collapse detail sections. To access a panel in a
nested repeater, I use the following code. The problem is I can get a
reference to a nested repeater, but can not use that reference to access the
panel within.

protected void rptrOrders_ItemCommand(object source,
System.Web.UI.WebControls.RepeaterCommandEventArgs e) {

Repeater rpt = (Repeater) e.Item.FindControl("rptrItems");

Panel pnl = (Panel) rpt.FindControl("panelItems"); // Problem here,
returns null

if (pnl.Visible == false) {

pnl.Visible = true;

}
else {

pnl.Visible = false;

}
}
 
G

Guest

The panel named "panelItems" would be within one of the items of the child
repeater. Try something like this:

foreach (RepeaterItem rpi in rpt.Items)
{
Panel pnl = (Panel) rpi.FindControl ("panelItems");
if ( pnl!= null) pnl.Visible =!pnl.Visible ;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top