Allen Guest

try { MicrosoftRuleWorld(); } catch ( FailedException ex ) { tryAgain(); } finally { InstallLinux(); }
posts - 16, comments - 32, trackbacks - 19

My Links

News

Article Categories

Archives

Post Categories

.NET

Monday, September 26, 2005

The interesting DropDownList ASP.NET control behavior

So if you've decided to use syntax such as this

myDropDownListBox.Items[0].Selected = true;

or

ListItem foo = myDropDownListBox.Items.FindByValue(”foo”);
foo.Selected = true;

you will get the 'A DropDownList cannot have multiple items selected' error.

Seems to me that if the code sets the Selected attribute on an item in a list which by definition can only have one item selected, that the ListItem instance would set the SelectedIndex automatically for me. Seems like a no-brainer. I guess Microsoft found some sort of use for this error being thrown from a DropDownList control - just don't ask me what that could be.

I guess I'd rather see that the DropDownList have DropDownList items if the Selected property was pretty much useless and will only cause errors if used in a DropDownList.

posted @ Monday, September 26, 2005 12:00 PM | Feedback (29) | Filed Under [ Coding with C# ]

Powered by: