Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6827145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:13:54+00:00 2026-05-26T22:13:54+00:00

I am dynamically creating a databound DropDownList control and adding it to placeholder in

  • 0

I am dynamically creating a databound DropDownList control and adding it to placeholder in a databound Repeater control which is a custom user control placed on a page with tabs.

The Id of the DropDownList is set dynamically, and for the generated HTML below it is Comp1A

The control creation and usage works fine, but when I try to find the control recursively, I am always getting null.

Here is the generated HTML:

<select class="formDropDownRating" id="MainContent_ContentPlaceHolder1_TabContainer1_tab1_CE1_Repeater1_Comp1A_0" name="ctl00$ctl00$MainContent$ContentPlaceHolder1$TabContainer1$tab1$CE1$Repeater1$ctl00$Comp1A">
    <option value="5">5 - Strongly Agree</option>
    <option value="4">4 - Agree</option>
    <option value="3">3 - Somewhat Agree</option>
    <option value="2">2 - Disagree</option>
    <option value="1">1 - Strongly Disagree</option>

</select>

To find the control I am calling

target = FindDropDownListControl("Comp1A");

with

see Jeff Atwood’s function

protected DropDownList FindDropDownListControl(string controlReference)
{
    Control root = this.Page.FindControl("ctl00"); //the Master page (the root control)
    var ddl = (DropDownList)MyApp.Utility.ExtensionMethods.FindControlRecursive(root, controlReference) as DropDownList; 
    return ddl;
}

Could anyone spot what could be the culprit? How can I get a reference to Comp1A?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:13:55+00:00Added an answer on May 26, 2026 at 10:13 pm

    I’m not 100% sure, because your code samples don’t include how the controls are created, but if my suspicions are correct, the problem is that the control is being created at a point in the Page Lifecycle where it gets wiped out on the postback.

    Where, exactly, is the control being created in the Page Lifecycle? If it’s not being ccreated in the right place, or too late in the cycle, then it won’t be preserved in the Viewstate on Postbacks.

    If possible, ensure that it’s being created in the Page_Init or else manually add it to Page_Init.

    This article explains it more fully.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF ListView control for which I am dynamically creating columns. One
Using DTS I'm dynamically creating an access database. After the file is created (which
I am dynamically creating a table which I want to have clickable rows. When
I have an ASPX page that is dynamically creating a gridview from a database
I am having a JSP page, where i am dynamically creating a Table data.
In a page, on the load event, I am dynamically creating controls for display
I am dynamically creating classes which contain spring beans, however the beans are not
I am dynamically creating a combobox like this: public Control GenerateList(Question question) { //
I am dynamically creating textboxes using document.createElement('input') and adding a break between them using
I am dynamically creating an HTML table by using a repeater. I have four

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.