[Download Sample Project]
This article briefly covers the implementation of two types that can be used to bind list controls, such as the DropDownList, in a strongly-typed manner to a SQL Server data source using stored procedures. I think the main application of this concept, as demonstrated by the sample code, is for menu and list controls that usually provide a friendly display value (name or text) and a hidden value, but there may be more. It could be used in any situation where you need a name-value pair collection.
The usefulness of this architecture is up for debate--it may be more work than it's worth--but I hope you'll find it is at least an interesting exercise. Please send me feedback on whether or not you think it is useful, whether you end up using it in a real application, and please rate the article using the rating system that is located at the bottom of the article pages.
There are basically two core types involved in this architecture, the NameValuePair and the NameValuePairCollection. The NameValuePair type has only two properties--Name and Value. It is the so-called "business" or "domain" object that represents an individual name-value pair (menu option).
The second type is, more or less, your standard collection type (the need for which will be replaced with generics in Whidbey), but it does have some custom functionality and data that give this a bit of umph. There are really three core additions to the basic collection functionality: FillFromDb, BindToListControl, and the BuildingParameters event (and related argument structure, delegate, and raising method).