postback find dynamic control problem

Discussion in 'ASP .Net' started by PCH, Nov 9, 2004.

  1. PCH

    PCH Guest

    I have an c# asp.net (.net 1.1) web page, viewstate on.

    The problem I am having is on the button click postback to update.

    Heres the situation:

    I have an asp table that has 1 header row.

    On load I loop through a count, say 0 to 3, and dynamically build rows, into
    the asp table.
    For each row there are a few cells. for each cell there is/are a textbox
    control(s), etc etc.

    it builds great, everything works well for display.

    When it posts back on a button click, I can no longer access those dynamic
    controls.

    I tried looping recursively through parent controls, but they dont exit,
    they are lost on postback. The recursive loop finds every single control on
    the page except those that I build dynamically and add to the ASP table
    dynamically.

    I also tried the request form object to look at each key. From that I can
    find the control keys/values, EXCEPT for those controls I designated as
    hidden, which i need!

    Any ideas?

    Thanks
     
    PCH, Nov 9, 2004
    #1
    1. Advertising

  2. You are correct. The controls are gone after postback.
    That's just how it works.
    When you dynamically create controls, you are expected to dynamically create
    them again upon postback.
    It shouldn't be too hard if you design carefully. You should be able to
    reuse the code that creates the controls in the first place.

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net


    "PCH" <> wrote in message
    news:...
    >I have an c# asp.net (.net 1.1) web page, viewstate on.
    >
    > The problem I am having is on the button click postback to update.
    >
    > Heres the situation:
    >
    > I have an asp table that has 1 header row.
    >
    > On load I loop through a count, say 0 to 3, and dynamically build rows,
    > into
    > the asp table.
    > For each row there are a few cells. for each cell there is/are a textbox
    > control(s), etc etc.
    >
    > it builds great, everything works well for display.
    >
    > When it posts back on a button click, I can no longer access those dynamic
    > controls.
    >
    > I tried looping recursively through parent controls, but they dont exit,
    > they are lost on postback. The recursive loop finds every single control
    > on
    > the page except those that I build dynamically and add to the ASP table
    > dynamically.
    >
    > I also tried the request form object to look at each key. From that I can
    > find the control keys/values, EXCEPT for those controls I designated as
    > hidden, which i need!
    >
    > Any ideas?
    >
    > Thanks
    >
    >
    >
     
    Steve C. Orr [MVP, MCSD], Nov 9, 2004
    #2
    1. Advertising

  3. PCH

    PCH Guest

    Greet.

    So the only way to get the values is the request form object?



    "Steve C. Orr [MVP, MCSD]" <> wrote in message
    news:...
    > You are correct. The controls are gone after postback.
    > That's just how it works.
    > When you dynamically create controls, you are expected to dynamically

    create
    > them again upon postback.
    > It shouldn't be too hard if you design carefully. You should be able to
    > reuse the code that creates the controls in the first place.
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://Steve.Orr.net
    >
    >
    > "PCH" <> wrote in message
    > news:...
    > >I have an c# asp.net (.net 1.1) web page, viewstate on.
    > >
    > > The problem I am having is on the button click postback to update.
    > >
    > > Heres the situation:
    > >
    > > I have an asp table that has 1 header row.
    > >
    > > On load I loop through a count, say 0 to 3, and dynamically build rows,
    > > into
    > > the asp table.
    > > For each row there are a few cells. for each cell there is/are a

    textbox
    > > control(s), etc etc.
    > >
    > > it builds great, everything works well for display.
    > >
    > > When it posts back on a button click, I can no longer access those

    dynamic
    > > controls.
    > >
    > > I tried looping recursively through parent controls, but they dont exit,
    > > they are lost on postback. The recursive loop finds every single

    control
    > > on
    > > the page except those that I build dynamically and add to the ASP table
    > > dynamically.
    > >
    > > I also tried the request form object to look at each key. From that I

    can
    > > find the control keys/values, EXCEPT for those controls I designated as
    > > hidden, which i need!
    > >
    > > Any ideas?
    > >
    > > Thanks
    > >
    > >
    > >

    >
    >
     
    PCH, Nov 9, 2004
    #3
  4. No, recreate the controls on postback, but let ASP.NET fill in the user
    selected values automatically.
    Then you can examine the control values normally.

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net


    "PCH" <> wrote in message
    news:%...
    > Greet.
    >
    > So the only way to get the values is the request form object?
    >
    >
    >
    > "Steve C. Orr [MVP, MCSD]" <> wrote in message
    > news:...
    >> You are correct. The controls are gone after postback.
    >> That's just how it works.
    >> When you dynamically create controls, you are expected to dynamically

    > create
    >> them again upon postback.
    >> It shouldn't be too hard if you design carefully. You should be able to
    >> reuse the code that creates the controls in the first place.
    >>
    >> --
    >> I hope this helps,
    >> Steve C. Orr, MCSD, MVP
    >> http://Steve.Orr.net
    >>
    >>
    >> "PCH" <> wrote in message
    >> news:...
    >> >I have an c# asp.net (.net 1.1) web page, viewstate on.
    >> >
    >> > The problem I am having is on the button click postback to update.
    >> >
    >> > Heres the situation:
    >> >
    >> > I have an asp table that has 1 header row.
    >> >
    >> > On load I loop through a count, say 0 to 3, and dynamically build rows,
    >> > into
    >> > the asp table.
    >> > For each row there are a few cells. for each cell there is/are a

    > textbox
    >> > control(s), etc etc.
    >> >
    >> > it builds great, everything works well for display.
    >> >
    >> > When it posts back on a button click, I can no longer access those

    > dynamic
    >> > controls.
    >> >
    >> > I tried looping recursively through parent controls, but they dont
    >> > exit,
    >> > they are lost on postback. The recursive loop finds every single

    > control
    >> > on
    >> > the page except those that I build dynamically and add to the ASP table
    >> > dynamically.
    >> >
    >> > I also tried the request form object to look at each key. From that I

    > can
    >> > find the control keys/values, EXCEPT for those controls I designated as
    >> > hidden, which i need!
    >> >
    >> > Any ideas?
    >> >
    >> > Thanks
    >> >
    >> >
    >> >

    >>
    >>

    >
    >
     
    Steve C. Orr [MVP, MCSD], Nov 9, 2004
    #4
  5. PCH

    ree32 Guest

    So that means you shouldn't create user controls for Items that use a
    Database to retrieve values for it. I.e. you will end up accessing the
    database on every postback?
    Isn't this a major flaw for user controls?
    Is there any around this?

    "Steve C. Orr [MVP, MCSD]" <> wrote in message news:<>...
    > You are correct. The controls are gone after postback.
    > That's just how it works.
    > When you dynamically create controls, you are expected to dynamically create
    > them again upon postback.
    > It shouldn't be too hard if you design carefully. You should be able to
    > reuse the code that creates the controls in the first place.
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://Steve.Orr.net
     
    ree32, Nov 16, 2004
    #5
  6. PCH

    ree32 Guest

    Ignore it does remember it.

    (ree32) wrote in message news:<>...
    > So that means you shouldn't create user controls for Items that use a
    > Database to retrieve values for it. I.e. you will end up accessing the
    > database on every postback?
    > Isn't this a major flaw for user controls?
    > Is there any around this?
    >
     
    ree32, Nov 16, 2004
    #6
    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. Larry Bud
    Replies:
    1
    Views:
    366
    bruce barker
    Jan 10, 2007
  2. gnewsgroup
    Replies:
    1
    Views:
    399
    gnewsgroup
    Feb 13, 2008
  3. Wybo Dekker
    Replies:
    1
    Views:
    396
    Yukihiro Matsumoto
    Nov 15, 2005
  4. vdvorkin
    Replies:
    0
    Views:
    437
    vdvorkin
    Feb 10, 2011
  5. vdvorkin
    Replies:
    3
    Views:
    863
    vdvorkin
    Feb 14, 2011
Loading...

Share This Page