title: asp.net mvc radio button state
body: <p>I'm trying out asp.net mvc for a new project, and I ran across something odd.  When I use the MVC UI helpers for textboxes, the values get persisted between calls.  But, when I use a series of radio buttons, the checked state doesn't get persisted.</p>
  
  <p>Here's an example from my view.</p>
  
  <pre><code>&lt;li&gt;
          &lt;%=Html.RadioButton("providerType","1")%&gt;&lt;label&gt;Hospital&lt;/label&gt;
          &lt;%=Html.RadioButton("providerType","2")%&gt;&lt;label&gt;Facility&lt;/label&gt;
          &lt;%=Html.RadioButton("providerType","3")%&gt;&lt;label&gt;Physician&lt;/label&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>When the form gets posted back, I build up an object with "ProviderType" as one of it's properties.  The value on the object is getting set, and then I RedirectToAction with the provider as a argument.  All is well, and I end up at a URL like "<a href="http://localhost/Provider/List?ProviderType=1" rel="noreferrer">http://localhost/Provider/List?ProviderType=1</a>" with ProviderType showing.  The value gets persisted to the URL, but the UI helper isn't picking up the checked state.</p>
  
  <p>I'm having this problem with listbox, <strike>dropdownlist</strike>, and radiobutton.  Textboxes pick up the values just fine.  Do you see something I'm doing wrong?  I'm assuming that the helpers will do this for me, but maybe I'll just have to take care of this on my own. I'm just feeling my way through this, so your input is appreciated.</p>
  
  <p><strong>Edit:</strong> I just found the override for the SelectList constructor that takes a selected value.  That took care of my dropdown issue I mentioned above.</p>
  
  <p><strong>Edit #2:</strong> I found something that works, but it pains me to do it this way.  I feel like this should be inferred.</p>
  
  <pre><code>&lt;li&gt;
    &lt;%=Html.RadioButton("ProviderType","1",Request["ProviderType"]=="1")%&gt;&lt;label&gt;Hospital&lt;/label&gt;
    &lt;%=Html.RadioButton("ProviderType", "2", Request["ProviderType"] == "2")%&gt;&lt;label&gt;Facility&lt;/label&gt;
    &lt;%=Html.RadioButton("ProviderType", "3", Request["ProviderType"] == "3")%&gt;&lt;label&gt;Physician&lt;/label&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>Hopefully someone will come up with another way.</p>