title: Binding DropDownList into MVC View
body: <p>Reading from here: <a href="http://www.asp.net/mvc/tutorials/javascript/working-with-the-dropdownlist-box-and-jquery/using-the-dropdownlist-helper-with-aspnet-mvc">ASP.NET MVC</a></p>
  
  <p>Action <code>SelectCategory</code> has been created inside controller -</p>
  
  <pre><code> public ActionResult SelectCategory() {
  
       List&lt;SelectListItem&gt; items = new List&lt;SelectListItem&gt;();    
       items.Add(new SelectListItem { Text = "Action", Value = "0"});    
       items.Add(new SelectListItem { Text = "Drama", Value = "1" });    
       items.Add(new SelectListItem { Text = "Comedy", Value = "2", Selected = true });    
  
       ViewBag.MovieType = items;
  
       return View();    
   }
  </code></pre>
  
  <p>I am not able to understand binding of Data in following line.</p>
  
  <pre><code>@Html.DropDownList("MovieType")
  </code></pre>
  
  <p>While binding data in similar way,</p>
  
  <pre><code>@Html.DropDownList("IdList");
  </code></pre>
  
  <p>I obtain following error- </p>
  
  <blockquote>
    <p>There is no ViewData item of type 'IEnumerable' that
    has the key 'IdList'.</p>
  </blockquote>
  
  <p><strong>Controller Action</strong>:</p>
  
  <pre><code>public ActionResult SelectId()
      {
          List&lt;SelectListItem&gt; items = new List&lt;SelectListItem&gt;();
          items.Add(new SelectListItem { Text = "MyId1", Value = "MyId1", Selected=true });
          items.Add(new SelectListItem { Text = "MyId2", Value = "MyId2" });
  
          ViewBag.IdList = items;
          return View();
      }
  </code></pre>
  
  <p>What am I missing ? Thank you for your help !</p>