title: MVC 3 helper for radiobuttonlist enum
body: <p>I need some help. I'm trying to build a view where I need groups of radiobuttons of enum types.
  I have several enum types(classes) like this:</p>
  
  <pre><code>[DataContract(Namespace = Constants.SomeDataContractNamespace)]
  public enum OneEnumDataContract
  {
      [Display(Name = "Text_None", Description = "Text_None", ResourceType = typeof(TextResource))]
      [EnumMember]
      None = 0,
  
      [Display(Name = "Text_Medium", Description = "Text_Medium", ResourceType = typeof(TextResource))]
      [EnumMember]
      Medium = 1,
  
      [Display(Name = "Text_Very", Description = "Text_Very", ResourceType = typeof(TextResource))]
      [EnumMember]
      Very = 2
  }
  </code></pre>
  
  <p>In my model(a datacontract, using WCF) I have this property for the enum datacontract:</p>
  
  <pre><code>    [DataMember(Order = 23)]
      [Display(Name = "EnumValue", Description = "EnumValue_Description", ResourceType = typeof(TextResource))]
      public OneEnumDataContract EnumClass1 { get; set; }
  </code></pre>
  
  <p>In my view I would try to make the group of radiobuttons like this(with a helper):</p>
  
  <pre><code>@Html.RadioButtonListEnum("EnumList1", Model.EnumClass1)
  </code></pre>
  
  <p>My helper:</p>
  
  <pre><code>public static MvcHtmlString RadioButtonListEnum&lt;TModel&gt;(this HtmlHelper&lt;TModel&gt; helper, string  NameOfList, object RadioOptions)
      {
          StringBuilder sb = new StringBuilder();
          //som other code for pairing with resourcefile...
  
          foreach(var myOption in enumTexts.AllKeys)
          {
              sb.Append("&lt;p&gt;");
              sb.Append(enumTexts.GetValues(myOption)[0]);
              sb.Append(helper.RadioButton(NameOfList, System.Convert.ToInt16(myOption)));
              sb.Append("&lt;/p&gt;");
          }
          return MvcHtmlString.Create(sb.ToString());
      }
  </code></pre>
  
  <p>This gives me the first enumvalue in <code>OneEnumDataContract</code>, <code>None</code>, as the parameter <code>RadioOptions</code>.
  How can I get all the enumvalues in the datacontract into the helper?</p>