recursive help please

  • Thread starter Thread starter rodchar
  • Start date Start date
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
 
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)
 
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
 
Back
Top