recursive help please

R

rodchar

hey all,
i have to 2 tables (Tbl1 and Tbl2) that's contained in a fieldset, which is
contained in a tablecell of a table, which is contained in a div, which is
contained in a panel (still with me?)

can someone please show me how to recursively get to both tables that
contains "Tbl" in the IDs?

thanks,
rodchar
 
B

bruce barker

trival:

// find all controls on page that start with "Tbl"

Control[] list = ControlWalker(this, delegate(Control ctl)
{
return ctl.ID != null && ctl.ID.StartsWith("Tbl");
});

......

public delegate bool ControlWalkerMatcher (Control ctl);
public Control[] ControlWalker(Control ctl, ControlWalkerMatcher matcher)
{
ArrayList list = new ArrayList();
if (matcher(ctl)) list.Add(ctl);
for (int i=0; i < ctl.Controls.Count; ++i)
{
Control[] childList = ControlWalker(ctl.Controls,matcher);
if (childList.Length > 0) list.AddRange(childList);
}
return (Control[]) list.ToArray(typeof(Control));
}


-- bruce (sqlwork.com)
 
R

rodchar

thanks bruce for the help.
rod.

bruce barker said:
trival:

// find all controls on page that start with "Tbl"

Control[] list = ControlWalker(this, delegate(Control ctl)
{
return ctl.ID != null && ctl.ID.StartsWith("Tbl");
});

......

public delegate bool ControlWalkerMatcher (Control ctl);
public Control[] ControlWalker(Control ctl, ControlWalkerMatcher matcher)
{
ArrayList list = new ArrayList();
if (matcher(ctl)) list.Add(ctl);
for (int i=0; i < ctl.Controls.Count; ++i)
{
Control[] childList = ControlWalker(ctl.Controls,matcher);
if (childList.Length > 0) list.AddRange(childList);
}
return (Control[]) list.ToArray(typeof(Control));
}


-- bruce (sqlwork.com)


rodchar said:
hey all,
i have to 2 tables (Tbl1 and Tbl2) that's contained in a fieldset, which is
contained in a tablecell of a table, which is contained in a div, which is
contained in a panel (still with me?)

can someone please show me how to recursively get to both tables that
contains "Tbl" in the IDs?

thanks,
rodchar
 

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

Similar Threads

I dont get this. Please help me!! 2
Please help 2
Code help please 4
Can't solve problems! please Help 0
HELP PLEASE 4
Please help me!!! 3
Please, help me. 1
Malicious Coding Help Please 5

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top