SharpPieces ExtendedDropDownList control - how it works

A really big problem with the standard ASP NET DropDownList control is that it lacks a major feature that the HTML select control already has: the option to define groups using the optgroup tag and add items to those groups.

This way, you provide a logical grouping, making the selection of an item by the user easier. The ExtendedDropDownList control now gives you this option, with an easy to use and flexible API to add items to groups.

Here is a list of features that the ExtendedDropDownList control has over the classic ASP NET DropDownList:

  • Ability to define groups using the optgroup tag, with ahn easy-to-use API.
  • Preserves state between postbacks for the custom attributes.
  • Strong-typed properties for defining the css class for Group and for item, using CssClass and GroupCssClass properties.

Okay, so you saw what the ExtendedDropDownList can do, now let's see how it works behind the hood. You will notice that we have a custom collection of ExtendedListItem objects, ExtendedItems.

What's the difference between ListItem and ExtendedListItem?
Basically none!
ExtendedListItem wraps a ListItem class, and provides some strong-typed properties for ease of use. All of the properties the ExtendedListItem has are actually attributes in the ListItem, and nothing more.