asp:DropDownList departmentDD has 0 elements.
In the code-behind I set departmentDD.SelectedIndex = 9;
In the debugger I see that departmentDD.SelectedIndex stays at 0.
I would expect it to throw an error, stay at zero, or switch to 9.
It stayed at 0. I'm ok with that.
Further down in the codebehind I do push some data into
departmentDD and departmentDD.databind.
Suddently departmentDD.SelectedIndex is equal to 9!
It remembered and set the value later once it could do it.
That's nice of it. I don't expect or want to object to be nice.
I want it to be consistant and predictable.
How many other weird quirks are in the web component objects?
So I ran another test.
asp:DropDownList departmentDD has 2 elements.
In the code-behind I set departmentDD.SelectedIndex = 1;
In the debugger I see that departmentDD.SelectedIndex is now 1.
I don't like this.
If it's going to some lame late update of selectedIndex when databound,
it should do it that way everytime.
Friday, May 15, 2009
.NET annoyance 6 - asp:DropDownList
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment