title: ASP.NET MVC DropDownList and HTML Attributes
body: <p>I am having a dropdownlist in my application in edit form. 
  But somewhere I was wrong.</p>
  
  <hr>
  
  <p><em>HomeController.cs</em></p>
  
  <pre><code>        ViewData["RealizatorID"] = from r in db.tGlavnas
             select new SelectListItem { Text = r.Realizator.ImeRealizatora, 
             Value = r.Realizator.ImeRealizatora, Selected = (r.RealizatorID == id) };
  </code></pre>
  
  <hr>
  
  <p><em>Edit.aspx</em></p>
  
  <pre><code>        &lt;div class="editor-label"&gt;
              &lt;%: Html.LabelFor(model =&gt; model.RealizatorID) %&gt;
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              &lt;%: Html.DropDownList("RealizatorID")%&gt;
              &lt;%: Html.ValidationMessageFor(model =&gt; model.RealizatorID) %&gt;
          &lt;/div&gt;
  </code></pre>
  
  <hr>
  
  <p>When recording changes in Edit.aspx page report following error to me:</p>
  
  <p>There is no ViewData item of type 'IEnumerable' that has the key 'RealizatorID'.</p>