title: Generic method and passing any enum as parameter
body: <p>All,</p>
  
  <p>I'm trying to sort out my last bits in a Enum-framework.</p>
  
  <p>My goal: I want to send <em>any</em> enum type and convert it to a List and bind it to a drop down list. i will use an ObjectDataSource as DataSource for the given drop down list. I want to create a composite control that only takes one parameter; enum type. The composite control will sort out databinding and all other bits and bops.</p>
  
  <p>Now, the only problem I have is to convert the generic method to be compatible with the ObjectDataSource.</p>
  
  <p>Here is the code for my current method that i need to use on my ObjectDataSource. So, this method is working fine and returns a list of items for the Enum type WeekDays. However, I need the same functionality, but I need to replace WeekDays with any type of enum.</p>
  
  <p>Code:</p>
  
  <pre><code>public class DropDownData
  {
  
      public EnumDataItemList GetList()
      {
          EnumDataItemList items = new EnumDataItemList();
  
          foreach (int value in Enum.GetValues(WeekDays))
          {
              EnumDataItem item = new EnumDataItem();
  
              WeekDays d = (WeekDays)value;
  
              //Set display text
              if (!string.IsNullOrEmpty(DataHandlers.GetAttributeValue&lt;DisplayTextAttribute, string&gt;(d)))
              {
                  //Translation logic goes here
                  item.Text = DataHandlers.GetAttributeValue&lt;DisplayTextAttribute, string&gt;(d);
              }
              else
              {
                  //Translation logic goes here
                  item.Text = Enum.GetName(typeof(WeekDays), value);  
              }
  
              item.Value = value; //Actual value
              item.ToolTip = DataHandlers.GetAttributeValue&lt;ToolTipAttribute, string&gt;(d);
              item.Description = DataHandlers.GetAttributeValue&lt;Lia.Library.Enums.CustomAttributes.DescriptionAttribute, string&gt;(d);
              item.HelpText = DataHandlers.GetAttributeValue&lt;HelpTextAttribute, string&gt;(d);
              item.ExcludeOnBinding = DataHandlers.GetAttributeValue&lt;ExcludeOnBinding, bool&gt;(d);
  
              if (!item.ExcludeOnBinding)
              {
                  items.Add(item);                    
              }
          }
          return items;
      }
  
  }
  
  public class EnumDataItemList : List&lt;EnumDataItem&gt;
  {
  
  }
  </code></pre>
  
  <p>As far as I know, I can't use a generic method with ObjectDataSOurce, but Generic Class is fine. I just can't get it to work with a generic class and all help is much appreciated. When all is working, I'll be happy to share the complete solution.</p>
  
  <p>I'm using Framework 2.0.</p>