Viewstate for dynamic controls within dynamically loaded usercontr

Discussion in 'ASP .Net' started by steven scaife, Oct 2, 2008.

  1. Hi

    I have been banging my head for a few days now with this issue.

    I have a page that has several update panels everything is working fine
    except for 1 thing.

    I am creating a sort of wizard that will build a form that I plan to save to
    a database
    On stage 2 I load a usercontrol an unspecified number of times depending on
    how many fields there will be and add it to an accordian pane.

    So if I have two fields there will be two accordian panes this all works fine

    Inside of the usercontrol there is a drop down list that adds textboxes
    and/or dropdown lists to a placeholder.

    When I postback the fields in the usercontrol maintain postback and the
    dropdown list has the value selected however the dynamically created controls
    appear but don't have any values that have been selected or entered into them.

    All the controls have the same ids so thats not the problem.

    The page on the load loops through and calls loadcontrol sets the id and
    adds the control to the accordianpane which is added to the accoridan.

    If i have my code in the init event the dropdown value is not preserved

    TIA
     
    steven scaife, Oct 2, 2008
    #1
    1. Advertising

  2. Don't worry about this I sorted it.

    for anyone else in the same position I did the following

    Added a readonly property to the usercontrol so I could determine whether
    the usercontrol ispostback was true or false. The ajax I have implemented
    always tells me it is a postback.

    I then removed the code from the dropdownlist_slectedindexchanged event and
    stuck it in page load when a postback was true so the viewstate information
    was pulled through.

    TA

    "steven scaife" wrote:

    > Hi
    >
    > I have been banging my head for a few days now with this issue.
    >
    > I have a page that has several update panels everything is working fine
    > except for 1 thing.
    >
    > I am creating a sort of wizard that will build a form that I plan to save to
    > a database
    > On stage 2 I load a usercontrol an unspecified number of times depending on
    > how many fields there will be and add it to an accordian pane.
    >
    > So if I have two fields there will be two accordian panes this all works fine
    >
    > Inside of the usercontrol there is a drop down list that adds textboxes
    > and/or dropdown lists to a placeholder.
    >
    > When I postback the fields in the usercontrol maintain postback and the
    > dropdown list has the value selected however the dynamically created controls
    > appear but don't have any values that have been selected or entered into them.
    >
    > All the controls have the same ids so thats not the problem.
    >
    > The page on the load loops through and calls loadcontrol sets the id and
    > adds the control to the accordianpane which is added to the accoridan.
    >
    > If i have my code in the init event the dropdown value is not preserved
    >
    > TIA
     
    steven scaife, Oct 3, 2008
    #2
    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. S. Justin Gengo

    Re: Dynamically Loaded UserControl and ViewState

    S. Justin Gengo, Feb 17, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,808
    S. Justin Gengo
    Feb 17, 2004
  2. Matt Howeson
    Replies:
    0
    Views:
    1,758
    Matt Howeson
    Mar 18, 2005
  3. =?Utf-8?B?V291dGVy?=

    Dynamically Loaded controls loading other controls

    =?Utf-8?B?V291dGVy?=, Feb 27, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    518
    =?Utf-8?B?V291dGVy?=
    Feb 27, 2006
  4. Thijs
    Replies:
    2
    Views:
    131
    Brenda
    Dec 4, 2003
  5. Joey G

    Dynamically Loaded Control and ViewState

    Joey G, Feb 17, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    150
    Joey G
    Feb 17, 2004
Loading...

Share This Page