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. 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. =?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:
    407
    Davide Vernole [MVP]
    Jul 13, 2004
  2. msimmons
    Replies:
    0
    Views:
    514
    msimmons
    Jul 16, 2009
  3. Chris Kennedy

    Referencing Dynamically created controls

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

    Build control in a placeholder or like a placeholder

    nail, Sep 10, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    352
  5. elkay
    Replies:
    5
    Views:
    252
    elkay
    Dec 22, 2004
Loading...

Share This Page