I just ran into a problem that I had never noticed before, and I want to know for some reason this is isolated from my current project, or if this is a problem that I need to panic about and check each of my applications and fix it right away .
I have two dropdowns on the same page using the same select list.
ex. HomeCity and CurrentCity are both populated from the same list of cities. Therefore, in code filled with the same IEnumerable<selectListItem>
It turns out that if the second value on the page is null (in the view model), then instead of using the optionLabel value by optionLabel , it defaults to the first value.
This problem is very annoying when (as I often do) you try to cache SelectList . Not only the next item on the same page has the wrong value, but the selected item changes in the cache (which is so strange because you can imagine that the cache serializes the values ββand gives you a copy.
So my question is twofold.
- Is this normal functionality, or did I somehow initiate this strange behavior?
- What is the recommended way to avoid this? Should I make a deep clone of my drop-down list picker?
Rabbi source share