title: How to Create an ASP.NET MVC HTML.DropDownList with Static Items?
body: <p>I would like to create a DropDownList containing 2 items: Part Name and <a href="http://en.wikipedia.org/wiki/NATO_Stock_Number" rel="nofollow noreferrer">NSN</a>.</p>
  
  <p>This dropdownlist will be used as part of a search box control that will be a partial render as part of my master page.  The user will enter their search text and select either Part Name or NSN from the dropdownlist and click submit.  The query will return results based on the searchtext.  I have defined PartsController and here's the pertinent portion of it:</p>
  
  <pre><code>    Function Search(ByVal searchtext As String, ByVal SearchType As String) As ActionResult
          Dim searchlist As List(Of String) = New List(Of String)
          searchlist.Add("Part Name")
          searchlist.Add("NSN")
          ViewData("searchlist") = New SelectList(searchlist)
  
          If SearchType = "PARTNAME" Then
              Dim SearchResult = From p In _entities.PartList _
                Where p.PARTNAME = searchtext _
                Select p
              Return View(SearchResult)
          End If
          If SearchType = "NSN" Then
              Dim SearchResult = From p In _entities.PartList _
                Where p.NSN = searchtext _
                Select p
              Return View(SearchResult)
          End If
          Return View("UnknownType")
      End Function
  </code></pre>
  
  <p>PartsForm.ascx is defined as follows:</p>
  
  <pre><code>    &lt;%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl(Of DielToolMVC.PartList)" %&gt;
      &lt;%=Html.ValidationSummary("Please correct the errors and try again")%&gt;
      &lt;%  Using (Html.BeginForm("Search", "PartsController"))%&gt;
          &lt;fieldset&gt;
              &lt;p&gt;
                  &lt;label for="Parts"&gt;Please enter a part description or NSN.&lt;/label&gt;
                  &lt;%=Html.TextBox("searchtext") %&gt;
                  &lt;%=Html.DropDownList("searchlist")%&gt;
                  &lt;%=Html.ValidationMessage("Part Name or NSN", "*")%&gt;
              &lt;/p&gt;
              &lt;p&gt;
                  &lt;input type="submit" value="Search" /&gt;
              &lt;/p&gt;
          &lt;/fieldset&gt;
      &lt;% End Using%&gt;
  </code></pre>
  
  <p>When I debug, I receive the following error message:</p>
  
  <blockquote>
    <p>There is no ViewData item with the key 'searchlist' of type 'IEnumerable'.</p>
  </blockquote>
  
  <p>I'm a bit confused as the <a href="http://en.wikipedia.org/wiki/Microsoft_Developer_Network" rel="nofollow noreferrer">MSDN</a> documentation demonstrates similar examples.  However, after following such examples I get this error.  What am I overlooking?</p>