Creating controls dynamically based on a dynamic control

Discussion in 'ASP .Net' started by =?Utf-8?B?TWF0dA==?=, Feb 4, 2005.

  1. Hi,

    Can someone provide some information on how to create a control dynamically
    based on the contents of another dynamic control.

    In my experience, all dynamic controls must be created in the Initialize
    stage of an ASP.Net page life cycle. Because viewstate is not available in
    the initialization stage, I cannot get the value of the 1st dynamic control
    to create the second control.

    I think building a server control would resolve this issue, but I'm looking
    for something a little more straight forward.

    Does anyone have any suggestions?
     
    =?Utf-8?B?TWF0dA==?=, Feb 4, 2005
    #1
    1. Advertising

  2. Create container control - for example Panel or Literal Control. Then on the
    server side add your dynamically created control like this:
    pnl.Controls.Add...

    Hope that helps!
    Regards,
    Kostadin Kostov

    "Matt" wrote:

    > Hi,
    >
    > Can someone provide some information on how to create a control dynamically
    > based on the contents of another dynamic control.
    >
    > In my experience, all dynamic controls must be created in the Initialize
    > stage of an ASP.Net page life cycle. Because viewstate is not available in
    > the initialization stage, I cannot get the value of the 1st dynamic control
    > to create the second control.
    >
    > I think building a server control would resolve this issue, but I'm looking
    > for something a little more straight forward.
    >
    > Does anyone have any suggestions?
     
    =?Utf-8?B?S29zdGFkaW4gS29zdG92?=, Feb 4, 2005
    #2
    1. Advertising

  3. I'm not sure how this will help. Both the panel and literal control are
    still populated based on viewstate, which is not available in the Initialize
    stage of the page life cycle.

    Maybe I wasn't clear with my question. I'm trying to figure out how to
    build a dynamic control based on the contents of another dynamic control.

    For example, let's say I have a dropdown box that is used to build a
    multitude of other controls on the page. This dropdown box is data bound and
    as such the information in the box is not available until after the
    LoadViewState stage. Unfortunately, I need to add my controls in the Init
    stage because my dynamically created controls need to be rebuilt from
    viewstate. If I add them in the Load stage, the viewstate information is
    lost. Can you see the catch 22 here?
     
    =?Utf-8?B?TWF0dA==?=, Feb 4, 2005
    #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. Ronald
    Replies:
    2
    Views:
    846
    Robbe Morris [C# MVP]
    Jan 17, 2006
  2. Tarscher
    Replies:
    9
    Views:
    408
    Russell
    Feb 13, 2007
  3. Replies:
    4
    Views:
    576
    Eliyahu Goldin
    Nov 1, 2007
  4. xz
    Replies:
    9
    Views:
    533
    James Kanze
    Jan 8, 2008
  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:
    467
    Eidolon
    May 4, 2004
Loading...

Share This Page