title: How to create a single select list box that shows the selection using Razor
body: <p>How do I create a simple, single select list box using the Razor view engine? I'm currently running into two problems. The first is that the list box "Select" code generated has 'multiple' automatically added. Question One is how to turn that off. No, I don't want to have to use a drop down list box. </p>
  
  <p>Question Two is trickier. The generated "Select" in the output html does not show any items as being selected, despite the item in question have selected values. Here's my code:</p>
  
  <p>Object model:</p>
  
  <pre><code>public class Description
  {
      public String code { get; set; }
      public SelectList codelist;
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>code = "drain";
  codelist = new SelectList(sourcelist, "Key", "Value", "drain");
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>@Html.ListBoxFor(model =&gt; model.code, Model.codelist)
  </code></pre>
  
  <p>Output HTML:</p>
  
  <pre><code>&lt;select data-val="true" data-val-required="The Select the permit type to apply for field is required." id="code" multiple="multiple" name="code"&gt;&lt;option value="drain"&gt;Interior Drain Repair&lt;/option&gt;
  ... yadda yadda yadda
  &lt;/select&gt;
  </code></pre>
  
  <p>You can see my two problems here. First, "multiple" has been added to the select list, and the selected option "drain" is not selected.</p>
  
  <p>Any suggestions? I'm at the point of just tossing Razor and hand coding this stuff.</p>