title: Drop Down List Across Views/Models
body: <p>I am trying to create a dropdown list, which is simple enough if the list is in the same view as the model/controller, however I am trying to create the dropdown list in another view. I am including the "using.samplemodel.Models;" using statement which seems to work as far as being able to access the right database, however no matter which method I use to call the list items in the Database (which is already populate) I keep getting the error "there is no key "Categories" or even i use the Id field in the statement, I am currently using the Viewbag option to call the database information, however, no matter which method I try, I still get the same error.</p>
  
  <pre><code> The class of the view I am wanting to use drop down list in:
  
  namespace Fake.Models
  {
      public class Fake
      {
          public int Id { get; set; }
          public List&lt;SelectList&gt; Categories { get; set; }
  
        }
  }
  
  
  
   Model of the Category class pulling from database:
  
  namespace Fake.Models
  {
      public class Categories
      {
          public int Id { get; set; }
          public string CategoryName { get; set; }
      }
  }
  
  
  
  
   controller of the view intended to use dropdown list:
  
  namespace Fake.Controllers
  {
      public class FakeController : Controller
      {
  
          FakeDb _db = new FakeDb();
  
  
          public ActionResult Index()
          {
              var model = from a in _db.Fake1 orderby a.Date ascending select a;
              ViewBag.Categories = new SelectList(_db.Categories, "Id", "CategoryName");
              return View(model);
          }
  
  
  
  
  The view I am trying to get dropdown list to work in:
  
  @model fakename.Models.Modelname
  @using (Html.BeginForm())
  {
      @Html.AntiForgeryToken()
  &lt;div class="form-group col-md-offset-2 col-md-10"&gt;
              @Html.DropDownList("Categories", "Select Category")
              // Omitted Info not related
          &lt;/div&gt;
  }
  </code></pre>
  
  <p>Sorry the Snippets here dont exatly match up as I intended with this form. So I am including a window snip of the code as jpeg here <a href="https://i.stack.imgur.com/qvbrk.jpg" rel="nofollow noreferrer">Code in Notepad Snip</a> Just in case.</p>