title: Simple DropDownListFor in MVC2?
body: <p>I've got a table that stores a True/False value as a sqlserver bit field (<code>Featured</code>). First, is there a better way to generate a dropdown list for this other than manually?</p>
  
  <p>Second, here's what I've got so far which works but does not add <code>selected="selected"</code> to any items in the DDL. </p>
  
  <p><strong>Edit 1:</strong> I've updated this example according to the answer suggested and it results in a run-time error :(
  <strong>Edit 2:</strong> Using it like a function works (with and without the cast) but selected="selected" is still not being added.</p>
  
  <p>Model:</p>
  
  <pre><code>//
  // View models
  public class SpotlightFormViewModel
  {
  
      // props
      public Spotlight Spotlight { get; private set; }
      public SelectList FeaturedMenu { get; private set; }
  
      static IDictionary&lt;string, int&gt; feature = new Dictionary&lt;string, int&gt;(){
          {"True", 1},
          {"False", 0},
      };
  
      public IEnumerable&lt;SelectListItem&gt; FeaturedChoices(Spotlight spotlight)
      {
          return feature.Select(f =&gt; new SelectListItem
          {
              Text = f.Key,
              Value = f.Value.ToString(),
              Selected = spotlight.Featured,
          });
      }
  
      // constr
      public SpotlightFormViewModel(Spotlight spotlight)
      {
          Spotlight = spotlight;
          FeaturedMenu = new SelectList(FeaturedChoices(spotlight));
      }
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>    public ActionResult Edit(int id)
      {
          Spotlight spotlight = spotlightRepository.GetSpotlight(id);
  
          return View(new SpotlightFormViewModel(spotlight));
      }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>        &lt;div class="editor-label"&gt;
              &lt;%: Html.LabelFor(model =&gt; model.Spotlight.Featured) %&gt;
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              &lt;%: Html.DropDownListFor(model =&gt; model.FeaturedMenu, Model.FeaturedChoices(Model.Spotlight))%&gt;
              &lt;%: Html.ValidationMessageFor(model =&gt; model.Spotlight.Featured) %&gt;
          &lt;/div&gt;
  </code></pre>