Skip to main content

Posts

Showing posts with the label Grouping

ASP.NET DropDownList with OptionGroup support

ASP.NET 2.0, for all its bells and whistles, lacks the odd bit of functionality for reasons completely unknown. One such notable omission is that of OptionGroup  ( < optgroup > ) support in the  DropDownList  control. For those unfamiliar with the  < optgroup >  element, it is part of the XHTML standard, and has the effect of categorising items in a  < select > , as the following image shows. Control Adapters are new in ASP.NET 2.0, and allow the developer to override the rendering behavior of any control, very powerful stuff! Furthermore, Control Adapters are used in conjunction with a browser file, so specific browsers may be targeted, if required. Armed with that knowledge, the solution became simple. The attached download contains the requisite files to implement this solution in your own projects, but for posterity, I paste it here also. public class DropDownListAdapter : System.Web.UI.WebControls.Adapters.WebCon...