title: Why can't I foreach through my ViewData or Model?
body: <p>I keep getting errors trying to iterate through my ViewData in the view there... I even tried strongly typing the view to IEnumerable(App.Models.Namespace) and using Model, to no avail. Either I get an error for lack of a GetEnumerable method or invalid type casting... Any idea how I do this?</p>
  
  <p>Model...</p>
  
  <pre><code>public IQueryable&lt;Product&gt; getAllProducts()
  {
      return (from p in db.Products select p);
  }
  </code></pre>
  
  <p>Controller...</p>
  
  <pre><code>public ActionResult Pricing()
  {
      IQueryable&lt;Product&gt; products = orderRepository.getAllProducts();
  
      ViewData["products"] = products.ToList();
  
      return View();
  }
  </code></pre>
  
  <p>View...</p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %&gt;
  
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"&gt;
      Pricing
  &lt;/asp:Content&gt;
  
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt;
  
      &lt;h2&gt;Pricing&lt;/h2&gt;
  
      &lt;div&gt;
          &lt;select class="product"&gt;
              &lt;%foreach(var prod in ViewData["products"]){%&gt;
                  &lt;option&gt;&lt;%=prod.Title %&gt;&lt;/option&gt;
              &lt;%} %&gt;
  
          &lt;/select&gt;&lt;select&gt;&lt;/select&gt;
      &lt;/div&gt;
  
  &lt;/asp:Content&gt;
  </code></pre>