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

  • SEARCH
  • Home
  • 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 3693892
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:25:52+00:00 2026-05-19T04:25:52+00:00

I have a page that contains dynamically generated Dropdown List controls and I want

  • 0

I have a page that contains dynamically generated Dropdown List controls and I want thant the dynamic dropdown list perform an AutoPostback to fill some other field using the value selected. This is the code I’m using to create dynamically the control:

        If (Not IsPostBack) Then 
          Dim newDDL As DropDownList = New DropDownList()
          AddHandler newDDL.SelectedIndexChanged, AddressOf ChangeValue
          newDDL.ID = "Level1"
          [fill the DropDownList]
          newDDL.Items.Insert(results.Count, New ListItem("", -1))
          newDDL.Width = "300"     
          newDDL.AutoPostBack = True
          newDDL.SelectedIndex = results.Count

          LevelDDLs.Controls.Add(newDDL)
          LevelDDLs.Controls.Add(New LiteralControl("<br /><br />"))
    End If

Control is correctly filled and rendered on ASP page but, after selecting a value, the page is reloaded (AutoPostBack is called) but the control is not diplayed and the sub is not called. I put a breakpoint into the ChangeValue sub but anything happens.

I read on some post that handler for the first DropDownList is not necessary but, how is it possible to tell DropDownList to call my sub after changevalue?

Could you help me, please?

many thanks,
Andrea

  • 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-19T04:25:53+00:00Added an answer on May 19, 2026 at 4:25 am

    You have to set the Dropdowns’ IDs, otherwise they wouldn’t recreate their selectedindex from ViewState and no events are raised. They have to get the same unique IDs on every postback.

    Every control that is added dynamically also must be recreated on every postbacks. That should be done in Page_Load at the latest because after this page life cycle stage the viewstate is saved.

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

Sidebar

Related Questions

I have a ASPX Page that contains several user controls, which are loaded dynamically
I have a page that contains multiple textarea elements. These textareas and the IDs
I have a requirement to print only part of a page. I cannot use
On a page, something like jsFiddle, that executes user inputed Javascript, is there a
I have some text that needs to be displayed in my app. The text
I have a website that presents Q&As to mathematical problems, mostly for pupils aged
I have a sharepoint site and want to create a script for links with
I have a collection of divs that contain either images or checkboxes. My end
I'm using a wizard control, step 1 has a list box with a list
I'm pretty new to Android app development, and I've been playing around with swipe

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.