MVC Bug with Default DropDownList or ListBox HTML Helpers

There are a lot of examples out there on how to pass a SelectList or MultiSelectList object to an Html.DropDownList or Html.ListBox helper.  However, I couldn’t find anything that was explaining the problem I was having. In my app we have a Show object that represents a podcast.  Each show may have multiple Guest objects, which are accessed by the Show.Guests member. In the Admin controller I have the following Action method: public ActionResult EditShow(int id) { var show = _repository.Get<Show>(id); show.Guests.Load(); var guestList = new MultiSelectList(_repository.List<Guest>().OrderBy(g => g.Name), "Id", "Name", show.Guests.Select(g => g.Id)); ViewData["GuestsSelectList"] = guestList; return View(show); }Read More

Getting things done – Sometimes simpler is better

I’m working on a new project for my work.  I’m using S#arp Architecture started by Billy McCafferty, which is a framework using ASP.Net MVC, NHibernate for database persistence and Ninject for dependency injection.  It’s really shaping up to be a great framework and I’m learning a lot. With NHibernate, you often come to the point where you have to map subclasses to your database.  The two prevailing strategies are one table per class or one table per class hierarchy.  You can look up any several dozen documents on these strategies.  For my project I chose one table per class hierarchyRead More

Unit Testing HtmlHelpers

I have a pretty decent project at my work that I am using ASP.Net MVC for.  It is a great framework and it’s my first real development project in a long time so I’m pretty excited. I’m really stealing myself to use TDD, with very heavy emphasis on the first D, “Driven”.  I’m not allowing myself to write a line of code without a test first.  It’s a little hard because IntelliSense is pretty meaningless in tests if the actual objects haven’t even been built.  When things get a little muddy I go and create a quick empty controller orRead More