title: How do I populate a Html.DropDownListFor<> with the data from an entity model?
body: <p>I am very new to to ASP.NET MVC 2, and I am having bucketloads of trouble to populate a dropdownlistfor&lt;> with the data from a entity model. I suspect my LINQ may be wrong, but it doesn't hurt to find out why my code is not working.</p>
  
  <p>I managed to pre-populate another DropDownListFor&lt;> with the following code:</p>
  
  <pre><code>        &lt;div class="editor-field"&gt;
              &lt;% string[] Days = new string[] { "Monday", "Wednesday", "Friday" };%&gt;
              &lt;%--&lt;%: Html.DropDownList("Delivery Day", new SelectList(Days)) %&gt;--%&gt;
              &lt;%: Html.DropDownListFor(model =&gt; model.DeliveryDay, new SelectList(Days))%&gt;
              &lt;%: Html.ValidationMessageFor(model =&gt; model.DeliveryDay)%&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>The list I am trying to populate now looks like this:</p>
  
  <pre><code>        &lt;div class="editor-field"&gt;
              &lt;%  List&lt;string&gt; categoryList = new List&lt;string&gt;();
                  var categories = from c in Model.Category select c.Category_Category;  
                  foreach (object cata in categories)
                  {
                      categoryList.Add(cata.ToString);
                  }%&gt;
              &lt;%: Html.DropDownListFor(model =&gt; model.Category_Category,new SelectList(categoryList))%&gt;
              &lt;%: Html.ValidationMessageFor(model =&gt; model.Category)%&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>This is what happens:</p>
  
  <p>Could not find an implementation of the query pattern for source type 'int?'. 'Select' not found.</p>
  
  <p>How can I fix this up?</p>