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 3316438
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:28:10+00:00 2026-05-17T22:28:10+00:00

While debugging a postback problem with a DropDownList within a Repeater I discovered that

  • 0

While debugging a postback problem with a DropDownList within a Repeater I discovered that even though everything looked like it was set up correctly the selections from the user on the DropDownList were not being restored from the view state.

My DropDownList was defined as

<asp:DropDownList ID="EmployeeColumnDropDownList" runat="server" Visible="True" />

VS2008 properties inspector indicates that EnableViewState is True
Visible is True as can be seen so it should be enabled. Yet stepping through with the debugger and tracing the Page_load, OnItemDataBound and the actual click_event I was interested in showed that the data wasn’t being populated from the view state.

The problem I was experiencing was that the selection made by the user wasn’t being picked up by my event handling code and it appeared to be reverting to what had been set up at the start of the page render on the initial page_load (which has the obligatory

if (!this.IsPostBack)

wrapper for populating the repeater and dropdown lists.

Inserting a specific enableViewState=”True” into my definition as follows solved the problem.

<asp:DropDownList ID="EmployeeColumnDropDownList" runat="server" Visible="True" EnableViewState="True" />

Remember that VS2008 was showing this as True anyway on the properties inspector.

Is this expected behaviour? or have I fluked a solution by forcing a condition through?

I’m asking the question as this seems a little odd and I don’t want this code to bite me later by suddenly stopping working.

EDIT to clarify how I am processing the code

I have a few dropdown lists that are generated using a repeater and are all populated from within the OnItemDataBound callback on each loop through the repeater.

I have a button outside the repeater that is hooked up to an onclick event handler. It is this handler which is not reading the correct user selection.

Edit – the viewstate appears to be a red herring

After hours of research and debugging I think the view state is a red herring.

I have a bug in here somewhere that is causing my drop down lists not to retain their selected state on the first postback (caused by a button click), When the form is returned they’ve lost their selection state (they still have the correct contents).

All subsequent postbacks, using the same button retain the correct selections. All code is the same as far as I can see for all postbacks.

it’s as if it isn’t merging the request parameters into the view state correctly for the very first postback.

I’m trying to set up a very simple example to dig into this, but it’s already lost me nearly a days work so far. I’ve been looking at merging the data myself but the presence of a repeater in my case is not making things easy.

  • 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-17T22:28:10+00:00Added an answer on May 17, 2026 at 10:28 pm

    OK Solved the mystery.

    I’m posting this here in case it helps someone else out in the future.

    I had a tiny piece of old code where I set up my drop down list, done centrally so I could apply it to three types of dropdownlist on the same page. This code was only called during the initial Page_Load event, however it was setting a new ID on the dropdownlist control therefore compromising the unique ids being created by the Repeater.

    On the first postback the entries in the viewstate weren’t matching up with the request data and this confused the runtime. On subsequent postbacks it seemed to get in step with itself.

    So my advice would be that if you are creating Dropdownlists, or I imagine other controls, within a Repeater or similar iterator then don’t mess with the ID fields if you want the built in functionality to work as expected.

    (Do any of the experienced people here think I should rename this question to something like “Don’t override the ID of a dropdownlist if created in a repeater”)

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

Sidebar

Related Questions

While debugging a problem I'm having on a DetailsView finding a control in one
While debugging a program in Xcode I have several CFStringRef variables that point to
While debugging crash in a multithreaded application I finally located the problem in this
I found something funny, I notice it by luck while I was debugging other
While debugging through a .NET 3.5 SP1 project which is contacting a local web
While debugging SQL statements, if I accidentally execute a query in using the mysql
While debugging some code, I came across an array named default . I thought
While debugging something, I saw the STL vector::empty() implementation: bool empty() const {return (size()
Does JQuery AJAX have a different User Session than a postback to the same
I am using a Listview in a usercontrol that I databind to a list

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.