UserControl ViewState with dynamic child controls

Discussion in 'ASP .Net Building Controls' started by ejstembler, Mar 1, 2006.

  1. ejstembler

    ejstembler Guest

    I have a custom UserControl where the content is dynamically generated
    when the containing Page calls a certain method (i.e. DisplayData).
    The content of the UserControl is a dynamically generated Table with
    several Rows and several Cells. Some of the Cells contain a TextBox
    which the end-user can type text into. The Page which contains this
    UserControl has a "Save" button which generates a post-back.

    The problem I'm having... When the end-user presses the "Save" button a
    post-back is generated, however, the UserControl's table is empty. I
    can save the table in the Session after generating it, but that doesn't
    give me access the the text from TextBoxes.

    Anyone know the proper way to do this?

    TIA.
     
    ejstembler, Mar 1, 2006
    #1
    1. Advertising

  2. ejstembler

    DWS Guest

    ejstembler,

    Try putting the save button in the user control.

    Good Luck
    DWS

    "ejstembler" wrote:

    > I have a custom UserControl where the content is dynamically generated
    > when the containing Page calls a certain method (i.e. DisplayData).
    > The content of the UserControl is a dynamically generated Table with
    > several Rows and several Cells. Some of the Cells contain a TextBox
    > which the end-user can type text into. The Page which contains this
    > UserControl has a "Save" button which generates a post-back.
    >
    > The problem I'm having... When the end-user presses the "Save" button a
    > post-back is generated, however, the UserControl's table is empty. I
    > can save the table in the Session after generating it, but that doesn't
    > give me access the the text from TextBoxes.
    >
    > Anyone know the proper way to do this?
    >
    > TIA.
    >
    >
     
    DWS, Mar 2, 2006
    #2
    1. Advertising

  3. ejstembler

    ejstembler Guest

    I cannot do that in this case.

    I see that this is a common issue after reading several posts here and
    the other ASP.Net newsgroups. Unfortunaly, I didn't find a solution.

    Basically I have a composite Control which dynamically generates child
    controls via CreateChildControls. However the this.Controls collection
    is empty after a post-back is fired and then CreateChildControls is
    eventually re-called. I just need to find a way to get the child
    controls to persist...


    DWS wrote:
    > ejstembler,
    >
    > Try putting the save button in the user control.
    >
    > Good Luck
    > DWS
    >
    > "ejstembler" wrote:
    >
    > > I have a custom UserControl where the content is dynamically generated
    > > when the containing Page calls a certain method (i.e. DisplayData).
    > > The content of the UserControl is a dynamically generated Table with
    > > several Rows and several Cells. Some of the Cells contain a TextBox
    > > which the end-user can type text into. The Page which contains this
    > > UserControl has a "Save" button which generates a post-back.
    > >
    > > The problem I'm having... When the end-user presses the "Save" button a
    > > post-back is generated, however, the UserControl's table is empty. I
    > > can save the table in the Session after generating it, but that doesn't
    > > give me access the the text from TextBoxes.
    > >
    > > Anyone know the proper way to do this?
    > >
    > > TIA.
    > >
    > >
     
    ejstembler, Mar 2, 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. Shimon Sim

    Id of child controls for UserControl

    Shimon Sim, Jun 17, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    690
    Kim Quigley
    Jun 17, 2005
  2. Replies:
    0
    Views:
    638
  3. Jeff Rodriguez
    Replies:
    23
    Views:
    1,204
    David Schwartz
    Dec 9, 2003
  4. Replies:
    0
    Views:
    220
  5. Donal McWeeney

    Mixing child properties and child controls - how?

    Donal McWeeney, Feb 10, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    135
    [MSFT]
    Feb 14, 2005
Loading...

Share This Page