Geeks With Blogs
The Life and Times of a Dev Yes, we're really that weird

I was fighting with a drop down list on Friday, and I never did figure out what was going on.

The list contains a set of all of the states in the US and the provinces in Canada and is bound to a DataSet.  The user fills out a simple form (city and state) and the clicks on search.  On the post back, server side, I looked for the value of the state, and it was always set to the first value in the dataset.

First thing I found was that the list was being reloaded on the page reload.  I took steps to stop that, but still, it didn't contain the value that was submitted back to the form.

I looked through all of the Request.Form values and found this:


However, that didn't match the ddlLocality.ClientId value, which was set to this:


No matter what I did, I couldn't get the locality box to post information back so that when I did a ddlLocality.SelectedValue, the value that was selected appeared, even though the value was set in in the Request.Form.

So to work around it, I did this:

   for (int i=0;i < Request.Form.Count;i++)
    if (Request.Form.Keys[i].IndexOf("ddlLocality") > 0)

Then in the state load, I set the value to what I found in the query string.  We're using dotnetnuke 2.1.2.  Anybody have any ideas why the value wouldn't be picked up by ASP.NET?


Posted on Monday, January 16, 2006 8:41 AM Work | Back to top

Comments on this post: DropDownList Trouble

# re: DropDownList Trouble
Requesting Gravatar...
This looks like a pre-patched ASP.Net 1.1

The IDs post-patch for both ClientID and that property are delimited with a more usable '$'.

Left by Eric Newton on Jan 16, 2006 12:16 PM

# re: DropDownList Trouble
Requesting Gravatar...
Interesting--I'm running version 1.1.4322.2300. Is there a hotfix that I'm not aware of?
Left by Robert May on Jan 16, 2006 12:44 PM

Your comment:
 (will show your gravatar)

Copyright © Robert May | Powered by: