Referencing Dynamically Created Controls in PlaceHolder

Discussion in 'ASP .Net Web Controls' started by Leona Vo via .NET 247, Jun 11, 2004.

  1. I was able to create dropdownlist dynamically and place them inplaceholder as follows:

    for i = 0 to 5
    Dim ShowDropDownList = New DropDownList
    ShowDropDownList.Visible = True
    ShowDropDownList.ID = "DropDownList" & i
    ShowDropDownList.Style("position") = "absolute"
    ShowDropDownList.Style("left") = "248px"
    ShowDropDownList.Style("top") = j & "px"
    PlaceHolder1.Controls.Add(ShowDropDownList)
    next

    I want to retrieve values from the dynamically created controls,in this case the dropdownlist controls. However, when the userclick on the submit button, the program no longer see thecontrols in PlaceHolder1. It appears that I have a view stateproblem, but I can't figure out a way around it. This is how Ireference the code and this is where I receive the error.

    for i = 0 to 5
    strWhereClause +=CType(PlaceHolder1.FindControl("DropDownList" & i),DropDownList).SelectedValue
    next

    Please help someone.
    --------------------------------
    From: Leona Vo

    -----------------------
    Posted by a user from .NET 247 (http://www.dotnet247.com/)

    <Id>RtjLC5aQBUO1t0f9pbTVKA==</Id>
     
    Leona Vo via .NET 247, Jun 11, 2004
    #1
    1. Advertisements

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. Jim Corey

    Referencing controls on user controls

    Jim Corey, Jan 26, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    463
    Hermit Dave
    Jan 26, 2004
  2. =?Utf-8?B?TWlrZQ==?=

    Referencing value of a dynamically created control

    =?Utf-8?B?TWlrZQ==?=, Jul 13, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    460
    Davide Vernole [MVP]
    Jul 13, 2004
  3. msnews.microsoft.com
    Replies:
    1
    Views:
    569
    =?Utf-8?B?Q2hyaXMgTW9oYW4=?=
    Sep 26, 2004
  4. msimmons
    Replies:
    0
    Views:
    755
    msimmons
    Jul 16, 2009
  5. Chris Kennedy

    Referencing Dynamically created controls

    Chris Kennedy, Apr 12, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    200
    ccallen
    Apr 12, 2004
  6. nail

    Build control in a placeholder or like a placeholder

    nail, Sep 10, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    513
  7. 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:
    646
    Eidolon
    May 4, 2004
  8. elkay
    Replies:
    5
    Views:
    357
    elkay
    Dec 22, 2004
Loading...