title: ASP.NET MVC dropdown-list from database
body: <p>Ok, so I'm new to this whole MVC-world, but it seems to be a pretty good way of getting things done and I'm trying to make it work here.</p>
  
  <p>The problem is:
  I can't get data from my table in my SQL-database to a simple drop-down form on my registration page.</p>
  
  <p>I have just no idea where to put the stuff, where to code to open the table, select the ids, where to put the <code>response.write</code> and how do I send it to the view?</p>
  
  <p>My Model is this:</p>
  
  <pre><code>    public class users
  {
      public string name {get; set;}
      public int user_id {get; set;}
  }
  </code></pre>
  
  <p>My Controller is this:</p>
  
  <pre><code>    [HttpGet]
      public ActionResult ListUser()
      {
          return View();
      }
  </code></pre>
  
  <p>And my View is this:</p>
  
  <pre><code>@model Community.Models.users
  </code></pre>
  
  <p>I have googled for 2 days now and watched several videos on youtube but of no use, I can't find it. Please, anyone with some knowledge here? And please point me to some good tutorials and/or forums where I can browse for more questions I might have</p>
  
  <hr>
  
  <p>Still no luck on this project..</p>
  
  <p>I'm creating a form and within that form, i want a db-loop (<code>IEnumerable</code>).. But the current model is not a <code>IEnumerable</code>. I'm pretty much stuck, watched a bunch of tutorials and they all just list ONE connection, what if I want two models?</p>
  
  <p>Here is my Controller, I get that you must pass a list to the view, right?</p>
  
  <pre><code>    public ActionResult Registration()
      {
          return View(db.users.ToList());
      }
  </code></pre>
  
  <p>How do i get hold of that list in my view witout an <code>IEnumerable</code> model?</p>
  
  <p>@neoistheone, your example didnt help me much, my DB opens like this:</p>
  
  <pre><code>private DataBaseContext db = new DataBaseContext();
  </code></pre>
  
  <p>and i don't know how, but it opens the connection.
  I've tried for so many hours now, its just silly, haven't slept for soo long!</p>
  
  <p>I'm used to programming ASP-Classic fyi, and this is my first serious try to upgrade my knowledge about programing an up-to-date language and OOP.</p>