title: .NET MVC 3 Adding attributes to SelectListItem in C#
body: <p>So I'm trying to stylize the  tag in a dropdown. My MVC helper is set up kind of like this but the real thing pulls from the DB, so the data is not hard coded.</p>
  
  <pre><code>@{
      List&lt;string&gt; ListOfText = new List&lt;string&gt; { "FirstThing","SecondThing","ThirdThing"};
      List&lt;string&gt; ListOfValue = new List&lt;string&gt; { "1","2","3"};
      List&lt;SelectListItems&gt; ListOFSELCETLISTITEMS = new List&lt;SelectListItem&gt;();    
  
      for (int x = 0; x &lt; 3; x++)
      {
          ListOFSELCETLISTITEMS .Add(new SelectListItem
          {
              Text = ListOfText[x],
              Value = ListOfValue[x],
              Selected = (selectedValue == ListOfValue[x])
          });
      }
  }   
  @Html.DropDown("NAME",ListOFSELCETLISTITEMS)
  </code></pre>
  
  <p>This gives me something like</p>
  
  <pre><code>&lt;select id="Name" name="Name"&gt;
      &lt;option value="1"&gt;FirstThing&lt;/option&gt;
      &lt;option value="2"&gt;SecondThing&lt;/option&gt;
      &lt;option value="3"&gt;ThirdThing&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>What i need is something like this</p>
  
  <pre><code>&lt;select id="Name" name="Name"&gt;
      &lt;option value="1" class="option1"&gt;FirstThing&lt;/option&gt;
      &lt;option value="2" class="option2"&gt;SecondThing&lt;/option&gt;
      &lt;option value="3" class="option3"&gt;ThirdThing&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>I've tried doing things like </p>
  
  <pre><code>@{
      List&lt;string&gt; ListOfText = new List&lt;string&gt; { "FirstThing","SecondThing","ThirdThing"};
      List&lt;string&gt; ListOfValue = new List&lt;string&gt; { "1","2","3"};
  }
  &lt;select id="Name" name="Name"&gt;
      @ for (int x = 0; x &lt; 3; x++)
      {
          &lt;text&gt;
          &lt;option value="@ListOfValue[x]" @{if(selectedValue == ListOfValue[x])
              { @Html.Raw("selected='selected'") }}
              @class = '@Html.Raw("option"+x)'&gt;
              @ListOfText[x]
          &lt;/option&gt;
          &lt;/text&gt;
      }   
  &lt;/select&gt;
  </code></pre>
  
  <p>But this seems to confuse the controller and it doesn't recognize that the dropdown's value above maps to </p>
  
  <pre><code>public ActionResult method(string Name)
  </code></pre>
  
  <p>in the controller on a post or get. Well the line</p>
  
  <pre><code> @Html.DropDown("NAME",ListOFSELCETLISTITEMS)
  </code></pre>
  
  <p>in the view does allow the controller to understand the method should map to that dropdown's value.</p>
  
  <p>How can i do this? Is there a way to unconfuse the controller and be able to hand write HTML without the Html.helpers?</p>