I think that ASP.NET MVC is a huge step forward from ASP.NET Web Forms. Still, there are some parts of it that are disappointing. One is the SelectList constructor, that doesn’t use generics and has string parameters for field selection. To create a SelectList from an IEnumerable<> we would do something like this. IEnumerable<Person> people… Continue reading Type Safe SelectList Factory
Tag: Extension Methods
Data Binding a Single Object when IEnumerable is Expected
Controls that can be used with data binding typically expect some kind of collection as the data source. One example is the ASP.NET DetailsView control. It displays a single record, but still expects a collection (to be exact: something that implements IEnumerable) to be assigned to its DataSource property. I use a small extension method… Continue reading Data Binding a Single Object when IEnumerable