title: Casting enum value to int when binding to dropdown using reflection
body: <p>I have some code that binds an enumeration to a dropdown list, however, I'd like build the dropdown to take the integer value from the enum for the value and the description attribute for the text.  </p>
  
  <p>I tried defining the kvPairList as a int/string and casting enumValue and an (int) 
  I also tried converting.toInt32</p>
  
  <p>Ideas?</p>
  
  <pre><code>&lt;select name="DropDownList1" id="DropDownList1"&gt; 
    &lt;option value="1"&gt;Option 1&lt;/option&gt; 
    &lt;option value="2"&gt;Option 2&lt;/option&gt; 
    &lt;option value="3"&gt;Option 3/option&gt;  
  &lt;/select
  </code></pre>
  
  <blockquote>
    <p></p>
  </blockquote>
  
  <p>Enum: </p>
  
  <pre><code>    using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using System.ComponentModel;
  
      namespace constants
      {
          public enum Options : int
          {
  
              [Description("Option 1")]
              Option1 = 1,
              [Description("Option 2")]
              Option2 = 3,
              [Description("Option 3")]
              Option3 = 3
          }
      }
  </code></pre>
  
  <p>Class:</p>
  
  <pre><code>using System;
  using System.Collections;
  using System.Collections.Generic;
  using System.Data;
  using System.Diagnostics;
  using System.ComponentModel;
  using System.Reflection;
  
  public class EnumDescription
  {
      public static string GetDescription(System.Enum value)
      {
          FieldInfo FieldInfo = value.GetType().GetField(value.ToString());
          DescriptionAttribute[] attributes = (DescriptionAttribute[])FieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);
  
          if ((attributes.Length &gt; 0))
              return attributes[0].Description;
          else
              return value.ToString();
      }
  
      public static List&lt;KeyValuePair&lt;string, string&gt;&gt; GetValuesAndDescription(System.Type enumType)
      {
          List&lt;KeyValuePair&lt;string, string&gt;&gt; kvPairList = new List&lt;KeyValuePair&lt;string, string&gt;&gt;();
  
          foreach (System.Enum enumValue in System.Enum.GetValues(enumType))
          {
              kvPairList.Add(new KeyValuePair&lt;string, string&gt;(enumValue.ToString(), GetDescription(enumValue)));
          }
  
          return kvPairList;
      }
  
  }
  </code></pre>