Data and controls from dynamically added controls is rmoved on Submit

Discussion in 'ASP .Net' started by David Hubbard, Jan 17, 2006.

  1. I place an PlaceHolder on a page and add a child control 1 or more times to
    it. Then the user enters values and clicks the submit button. When my event
    handler is called the controls are not present meaning:

    ChildPlaceHolder.Controls.Count

    is 0.

    I know Page_Load is called before my handler, does that regenerate the page
    before I have a chance to get the values in the child controls. If so do I
    need to add identifiers to the controls so that I can identify them in
    Page_Load to tell what button was pressed and call the appropriate handler
    before they are cleared.

    Thanks
    David Hubbard, Jan 17, 2006
    #1
    1. Advertising

  2. David Hubbard

    Bruce Barker Guest

    on the postback, you need to add the controls before the onload event, say
    in the oninit event (with the same names), so that they exist to receive
    their postback values.

    -- bruce (sqlwork.com)



    "David Hubbard" <> wrote in message
    news:...
    >I place an PlaceHolder on a page and add a child control 1 or more times to
    > it. Then the user enters values and clicks the submit button. When my
    > event
    > handler is called the controls are not present meaning:
    >
    > ChildPlaceHolder.Controls.Count
    >
    > is 0.
    >
    > I know Page_Load is called before my handler, does that regenerate the
    > page
    > before I have a chance to get the values in the child controls. If so do I
    > need to add identifiers to the controls so that I can identify them in
    > Page_Load to tell what button was pressed and call the appropriate handler
    > before they are cleared.
    >
    > Thanks
    Bruce Barker, Jan 17, 2006
    #2
    1. Advertising

  3. thanks bruce that did the trick.
    David Hubbard, Jan 17, 2006
    #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. Matthew Smith

    Dynamically added controls and postback

    Matthew Smith, May 16, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    502
    =?Utf-8?B?Q2hyaXM=?=
    May 16, 2004
  2. Phil Winstanley [Microsoft MVP ASP.NET]

    Re: Dynamically added controls and postback

    Phil Winstanley [Microsoft MVP ASP.NET], May 16, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    415
    Phil Winstanley [Microsoft MVP ASP.NET]
    May 16, 2004
  3. Jeff H.
    Replies:
    1
    Views:
    587
    el_khiyari
    Apr 14, 2005
  4. Jeffrey Todd
    Replies:
    1
    Views:
    4,080
    Peter Blum
    Jun 2, 2005
  5. ENathan

    existing controls overlaying dynamically added controls

    ENathan, Jan 10, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    189
    Steve C. Orr [MVP, MCSD]
    Jan 10, 2005
Loading...

Share This Page