Results 1 to 2 of 2

Thread: [RESOLVED] "Get" dynamcially created user controls in code-behind.

  1. #1

    Thread Starter
    Hyperactive Member Krokonoster's Avatar
    Join Date
    Jan 2010
    Location
    Cape Town
    Posts
    448

    Resolved [RESOLVED] "Get" dynamcially created user controls in code-behind.

    I dynamically build up a table of dates/hours worked by a user.
    Last row, for each date (column) contains a little user control where the user can enter some text.

    The user control work with some jQuery/UI and I will end up with each control have a date and reason set in hidden controls.

    How do I get hold of these controls only when the user click a button in the code-behind? (silly question I know, but I'm not used to how webforms does its' thing)


  2. #2

    Thread Starter
    Hyperactive Member Krokonoster's Avatar
    Join Date
    Jan 2010
    Location
    Cape Town
    Posts
    448

    Re: "Get" dynamcially created user controls in code-behind.

    I solved this one with the following recursive function:
    Wasted my time with GetType and typeOf.

    Code:
    protected IList<DisputeEntry> GetControls(Control control)
    {
        foreach (Control ctrl in control.Controls)
        {
            if (ctrl is DisputeEntry) 
            {
                var dispute = (DisputeEntry)ctrl;
                disputes.Add(dispute);
            }
            GetControls(ctrl);
        }
        return disputes;
    }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width