3 Replies Latest reply on Jan 27, 2011 7:32 AM by JasonRDP

    Best way to handle selectedItem in a DropDownList with changing data

    JasonRDP

      I am looking for input on how you would handle this situation.  I am having a problem maintaining the selectedItem in a DropDownList which is comprised of values that are populated from a server at regular intervals. So, let's say that that I have a list of Animals, with the names Cat, Dog, and Bird, and Cat is the selectedItem.  Well, I have that list bound to a collection which I then refresh from the server every 5 minutes.  So, when the new Cat, Dog and Bird objects are returned from the server and put in that collection, the Cat item is deselected, and it looks like because it's actually a different object, with a different Object ID.  I tried saving off the selected item, populating the collection with the new data, and then going through the items in the collection to find the Cat and then setting the selected item, but I am having limited success with it. I am sure it's just a logic error on my part. But I can't help but think there must be an easier way than this to handle the situation.

       

      Any thoughts?