Dropdown box within an ascx control

Results 1 to 2 of 2

Thread: Dropdown box within an ascx control

  1. #1
    Join Date
    Dec 1969

    Default Dropdown box within an ascx control

    I have a aspx page with a custom control .ascx file within it. The ascx control has a dropdown box and a button. When the button is clicked I want to take the value from the dropdown box and do something with it. Problem is no matter what I do it thinks the index is at zero. When I try autopostback it sets itself back to index zero. I have tried enableviewstate to true and it still does it. Anybody have an I idea of what I am doing wrong.

  2. #2
    Join Date
    Dec 1969

    Default Populate within IsPostBack block...

    Make sure that in your page_load event or whenever you are populating this drop down that you are enclosinig this code within an If IsPostBack Then... block. If you are not doing this, asp.net will repopulate the control every time the page loads, thus providing the effect that you are encountering. From there asp.net's state management will make sure that the control is populated. If you wish to change the items in the list, then you repopulate whenever it is appropriate.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts