title: How to bind dropdown list in ASP.NET MVC from SQL Server database?
body: <p>I don't know how to make view from this code to show data in dropdown list. Please do tell me what changes I can make to solve my problem. I have tried some view but this causes errors.</p>
  
  <p>Model:</p>
  
  <pre><code>public class Cities
  {
      public int cityid { get; set; }
      public string Description { get; set; }
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>public ActionResult Dropdownlist()
  {
      List&lt;Citites&gt; cityname= new List&lt;Citites&gt;();
      string constring = ConfigurationManager.ConnectionStrings["dbx"].ConnectionString;
  
      SqlConnection con = new SqlConnection(constring);
  
      SqlCommand cmd = new SqlCommand("SELECT Cityid, Description FROM Cities", con);
  
      con.Open();
  
      SqlDataReader rdr = cmd.ExecuteReader();
  
      while (rdr.Read())
      {
          Citites ci = new Citites();
          ci.cityid = Convert.ToInt32(rdr["Cityid"]);
          ci.Description = rdr[1].ToString();                
          cityname.Add(ci);
      }
  
      return View(cityname);
  }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>@model IEnumerable&lt; RegisterForm_crud_mvc_.Models.Citites&gt;
  @{
      ViewBag.Title = "Dropdownlist";
  }
  
  &lt;h2&gt;Dropdownlist&lt;/h2&gt;
  
  @Html.DropDownListFor(model =&gt; model.cityid, Model.citynanme)
  </code></pre>