title: Convert List to IEnumerable<SelectListItem>
body: <p>Tricky problem here. I'm trying to convert items for a list to <code>IEnumerable&lt;SelectListItem&gt;</code>.</p>
  
  <h2>Lists</h2>
  
  <p><code>dynamicTextInDatabase</code> simply returns all the Enums that are used in my database. Currently only returns 1 and 2. The data class simple holds an int value.</p>
  
  <p><code>dynamicTextEnumsInDatabase</code> is the same list as above just in the class that actually stores my Enums.</p>
  
  <p><code>dynamicTextEnumsAll</code> is a list of all the Enums that are available in my application. Currently: 1, 2 and 3.</p>
  
  <p><code>dynamicTextEnumsAvaiable</code> is a list of all the unused Enums. It combines All the Enums and then removes the ones that are in the database list.</p>
  
  <p>I need to pass the <code>dynamicTextEnumsAvaiable</code> to my View via the ViewBag to display in a drop-down list. However, It must be <code>IEnumerable&lt;SelectListItem&gt;</code> rather than a <code>List</code>.</p>
  
  <h2>Code</h2>
  
  <pre><code>        var dynamicTextInDatabase = new List&lt;DynamicTextEnumData&gt;();
          var dynamicTextEnumsInDatabase = new List&lt;DynamicTextEnum&gt;();
          var dynamicTextEnumsAll = new List&lt;DynamicTextEnum&gt;();
          IEnumerable&lt;SelectListItem&gt; list;
  
          using (var proxy = new Proxy&lt;IDynamicText&gt;())
          {
              dynamicTextInDatabase = proxy.Channel.DynamicTextGetActiveEnums(Helper.GetCallingUser());
          }
  
          foreach (DynamicTextEnumData item in dynamicTextInDatabase)
          {
              var dynamicTextEnum = (DynamicTextEnum)item.DynamicTextEnum;
              dynamicTextEnumsInDatabase.Add(dynamicTextEnum);
          }
  
          foreach (DynamicTextEnum item in Enum.GetValues(typeof(DynamicTextEnum)))
          {
              dynamicTextEnumsAll.Add(item);
          }
  
          var dynamicTextEnumsAvaiable = dynamicTextEnumsAll.Except(dynamicTextEnumsInDatabase).ToList();
  
          if (dynamicTextEnumsAvaiable.Count == 0)
          {
              TempData["Error"] = "To update the text of a message or warning, please select it from the grid below.";
              return RedirectToAction("Index");
          }
  
          ViewBag.AvaiableEnums = dynamicTextEnumsAvaiable;
          return View();
  </code></pre>