Generic Web Controls and EnumDropDownList

Date Published: 05 December 2007

Generic Web Controls and EnumDropDownList

I just published an article on ASPAlliance that shows a few different techniques for binding a DropDownList control in ASP.NET to an enumerated type (enum). As part of the article, I wrote a custom control that uses generics to bind a DropDownList to an enum. Unfortunately, I ran into problems with declaratively defining this control within ASP.NET markup, and thus far there is no support from the ASP.NET engine for generic types within the markup (though it has been discussed here). In response to my question about this support,Eilon Lipton blogged another approach that uses a ControlBuilder to allow specification of the proper control and its associated generic type within the ASP.NET markup, and is worth a read if this problem is of interest to you. If you think Microsoft should standardize on some markup for generics within ASP.NET markup and support it in ASP.NET 4.0, please leave a comment, since I know they read this blog.

Steve Smith

About Ardalis

Software Architect

Steve is an experienced software architect and trainer, focusing on code quality and Domain-Driven Design with .NET.