Search code examples
asp.netdesign-decisions

Is there a reason that ASP.NET's CheckBoxList doesn't have a SelectedItems member?


Whenever I want to get selected items I have to loop through each item and see if it's selected. They even have a SelectedItem (no "s" at the end) member which seems odd for a CheckBoxList. It seems like a logical thing to have, does anyone know why they haven't added it?


Solution

  • Because they're not implementing the SelectedItem in CheckBoxList, but in ListControl that CheckBoxList inherits from. It can be argued that CheckBoxList needs to be taken back to source, as many of the ways that it is written are just not "correct" but that's a subjective argument. (this is the subject of a personal rant, I've just come across too many cases of CheckBoxList doing something obtusely and it's annoying, is all. Just not the way my mind works I suppose, and have never had others corroborate that it is annoying to them too.)