By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,928 Members | 1,752 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,928 IT Pros & Developers. It's quick & easy.

Accessing child controls of a nested repeater control

P: n/a
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;

}
}
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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 ;
}
--
HTH,
Phillip Williams
http://www.societopia.net/Samples
http://www.webswapp.com
"Charlie@CBFC" wrote:
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;

}
}

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.