title: Problem populating dropdown boxes in an ASP.NET MVC 3 Application
body: <p>I have completed the new tutorial (musicstore) on MVC 3 over on  <a href="http://www.asp.net/mvc/tutorials/mvc-music-store-part-1" rel="nofollow">www.asp.net</a>. It all went fine except for the part where two dropdown boxes should be populated from the database - and they are not.</p>
  
  <p>I followed the tutorial and double checked my code. I think the problem may be using the editorstemplate folder. No idea really since Im new to MVC. So whats the problem or how can I debug it?</p>
  
  <p>==============</p>
  
  <h1>Edit 1</h1>
  
  <p>okay so here is some of the code for album.cshtml which is in the /views/shared/editortemplates/ folder</p>
  
  <pre><code>   @model MvcMusicStore.Models.Album
  &lt;p&gt; @Html.LabelFor(model =&gt; model.Genre) @Html.DropDownList("GenreId",
  new SelectList(ViewBag.Genres as System.Collections.IEnumerable,
  "GenreId", "Name", Model.GenreId))
  &lt;/p&gt;
  &lt;p&gt; @Html.LabelFor(model =&gt; model.Artist) @Html.DropDownList("ArtistId",
  new SelectList(ViewBag.Artists as System.Collections.IEnumerable,
  "ArtistId", "Name", Model.ArtistId))
  &lt;/p&gt;
  </code></pre>
  
  <p>which I believe is populated from:</p>
  
  <pre><code>public ActionResult Edit(int id)
  { ViewBag.Genres = storeDB.Genres.OrderBy(g =&gt; g.Name).ToList(); ViewBag.Artists = storeDB.Artists.OrderBy(a =&gt; a.Name).ToList();
  var album = storeDB.Albums.Single(a =&gt; a.AlbumId == id);
  return View(album);
  }
  </code></pre>
  
  <p>I don't get any errors apart from the fact the dropdowns are not populated...</p>
  
  <p>==============</p>
  
  <h1>Edit 2</h1>
  
  <p>so I have edit.cshtml in the /views/storemanager/edit.cshtml and then I have album.cshtml in /views/shared/editortemplates/album.cshtml. The dropdowns are supposed to be populated from album.cshtml into edit.cshtml. I put the code from album.cshtml directly into edit.cshtml and it works fine. So I think the problem is that the editortemplates/album.cshtml is not working i.e. populating the edit.cshtml page. So what gives? Thanks...</p>
  
  <p>==============</p>
  
  <h1>Edit 3</h1>
  
  <p>Ok I found the problem, I got the working source from CodePlex. It seems I didnt have the create.cshtml and edit.cshtml pages setup properly.
  Anyway all fixed now so thanks...</p>