Persisting dynamic controls

Discussion in 'ASP .Net' started by dougloj, Jul 21, 2006.

  1. dougloj

    dougloj Guest

    Hi,

    In my ASP.NET application, I want to be able to dynamically create
    RadioButtonLists and/or
    CheckBoxLists according to what is in my database. I wrote routines to
    create RadioButtonLists and CheckBoxLists. Each routine pulls data out
    of my database, populates the respective control, and passes the
    control back to the caller. The caller places the returned controls
    into a table. The controls are displayed as expected.

    However, after a postback is invoked as a result of a selection change
    in one of the RadioButtonLists or CheckBoxLists, all of my
    dynamically created RadioButtonList and/or CheckBoxLists disappear.

    Can anybody please tell me how to prevent the disappearing trick?

    Thanks for the bandwidth.

    Doug
     
    dougloj, Jul 21, 2006
    #1
    1. Advertising

  2. dougloj

    Teemu Keiski Guest

    You need to add control to Controls collection before populating it. if your
    method instantiates the control, populates it, and after that it's added to
    Controls collection, state management hasn't been triggered on, and Items
    aren't stored to ViewState.

    For a list of related references see:
    http://aspadvice.com/blogs/joteke/archive/2006/01/06/14568.aspx


    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke


    "dougloj" <> wrote in message
    news:...
    > Hi,
    >
    > In my ASP.NET application, I want to be able to dynamically create
    > RadioButtonLists and/or
    > CheckBoxLists according to what is in my database. I wrote routines to
    > create RadioButtonLists and CheckBoxLists. Each routine pulls data out
    > of my database, populates the respective control, and passes the
    > control back to the caller. The caller places the returned controls
    > into a table. The controls are displayed as expected.
    >
    > However, after a postback is invoked as a result of a selection change
    > in one of the RadioButtonLists or CheckBoxLists, all of my
    > dynamically created RadioButtonList and/or CheckBoxLists disappear.
    >
    > Can anybody please tell me how to prevent the disappearing trick?
    >
    > Thanks for the bandwidth.
    >
    > Doug
    >
     
    Teemu Keiski, Jul 21, 2006
    #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. Assaf

    Persisting dynamic controls

    Assaf, May 19, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    452
  2. Stu
    Replies:
    3
    Views:
    4,975
  3. Ronald
    Replies:
    2
    Views:
    850
    Robbe Morris [C# MVP]
    Jan 17, 2006
  4. Chris S.

    Persisting Dynamic Objects?

    Chris S., Jun 26, 2004, in forum: Python
    Replies:
    2
    Views:
    302
    Chris S.
    Jun 27, 2004
  5. Denny Smolinski via .NET 247

    Dynamic Controls, Placeholder, Retrieve Information from Dynamic Controls

    Denny Smolinski via .NET 247, May 4, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    470
    Eidolon
    May 4, 2004
Loading...

Share This Page