Bound Drop Down List changes to first item in list


I have two drop down list on a page. The first one list projects and the second list users.

The userlist is populated with an object datasourse that pulls a list of users for the selected Project.

Whenever the Project list selection changes the second ddl Userlist always reverts to the first person in the list instead the person that was selected before a new Project was chosen.

I want to be able to select a new project and not have the selected person in the UserList change.


You'll need to store the Id of the user that is currently selected before you do you databinding. One way would be to handle SelectedIndexChanged on your Project ddl so that you can grab the user id of the selected item in your User ddl then do the binding manually. Once the binding is done, then you can attempt to set the SelectedValue of the ddl to the User Id you had stored.

EDIT: Added an example:

In your aspx:

<asp:DropDownList ID="projectddl" runat="server" AutoPostBack="true" OnSelectedIndexChanged="projectddl_SelectedIndexChanged"> <asp:ListItem Text="Project 1" Value="1" /> <asp:ListItem Text="Project 2" Value="2" /> <asp:ListItem Text="Project 3" Value="3" /> </asp:DropDownList> <asp:DropDownList ID="usersddl" runat="server"> </asp:DropDownList>

In your code-behind:

protected void projectddl_SelectedIndexChanged(object sender, EventArgs e) { string currentlySelectedUserId = usersddl.SelectedValue; // Do your user databinding here based on project selected usersddl.SelectedValue = currentlySelectedUserId; }


  • Swift Socket.io the event sent right after connection is not executed
  • dynamically deleting tab panel in tab container in asp.net using vb.net
  • Powershell-search for users whos account expires with the office information
  • How to read a specified String from an input file, then read the next word after it
  • HTTPS + gzip: Is it a security vulnerability if I only gzip non-sensitive files?
  • How to produce a Code 39 that can be reliably read after faxing
  • What is the difference between GetComponent ().enabled and .SetActive (false); in unity
  • Youtube Video Player Fullscreen click event
  • How to do JOIN ON query using Criteria API
  • Pandas: merge_asof() sum multiple rows / don't duplicate
  • Mockery and Laravel constructor injection
  • How to access recipient on sent messages page with mailboxer
  • Flash radiobutton: how do I get the selected radiobutton?
  • Does Apportable support to build library binary (.a/.so)?
  • How to specify input and output paths from cmd.exe for a PowerShell script?
  • Looking for good analogy/examples for monitor verses semaphore
  • Jenkins: FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
  • Switching to Release Build causes runtime error in Web Reference
  • How do I change content of ComboFieldEditor?
  • Is there any way to access browser form field suggestions from JavaScript?
  • Incrementing object id automatically JS constructor (static method and variable)
  • How to check if every primary key value is being referenced as foreign key in another table
  • Can I have the cursor start on a particular column by default in jqgrid's edit mode?
  • Weird JavaScript statement, what does it mean?
  • ORA-29908: missing primary invocation for ancillary operator
  • jquery mobile loadPage not working
  • Do I've to free mysql result after storing it?
  • How to get next/previous record number?
  • QuartzCore.framework for Mono Develop
  • Calling of Constructors in a Java
  • Traverse Array and Display in markup
  • Transpose CSV data with awk (pivot transformation)
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • SQL merge duplicate rows and join values that are different
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • How do you join a server to an Active Directory (domain)?
  • How to stop GridView from loading again when I press back button?
  • How does Linux kernel interrupt the application?