recursive help please

Discussion in 'ASP .Net' started by rodchar, Dec 5, 2007.

  1. rodchar

    rodchar Guest

    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
     
    rodchar, Dec 5, 2007
    #1
    1. Advertising

  2. rodchar

    bruce barker Guest

    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" wrote:

    > 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
     
    bruce barker, Dec 5, 2007
    #2
    1. Advertising

  3. rodchar

    rodchar Guest

    thanks bruce for the help.
    rod.

    "bruce barker" wrote:

    > 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" wrote:
    >
    > > 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
     
    rodchar, Dec 5, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    565
    Chris Uppal
    May 5, 2005
  2. KK
    Replies:
    2
    Views:
    706
    Big Brian
    Oct 14, 2003
  3. MuZZy
    Replies:
    7
    Views:
    1,822
    Mike Hewson
    Jan 7, 2005
  4. n00m
    Replies:
    12
    Views:
    1,141
  5. vamsi
    Replies:
    21
    Views:
    2,147
    Keith Thompson
    Mar 9, 2009
Loading...

Share This Page