title: MVC DropDown from DataBase
body: <pre><code>public class DropDown
  {
  
      public string[] SelectedItems { get; set; }
  
      public IEnumerable&lt;SelectListItem&gt; Items { get; set; }
  
  }
  </code></pre>
  
  <p>Am trying to get a DropDown in MVC from DB with above structure.</p>
  
  <p>From DataBase I got the Text and value field and having in <code>IEnumerable&lt;T&gt;</code> where T has 2 properties id and text.</p>
  
  <p>What is the best way convert ienumerable id to array of string and assign id, text to <code>SelectedListItem</code> ?</p>
  
  <p>I thought of looping through the ienumerable and forming the DropDown, but thought there will be better ways.</p>
  
  <h1>update</h1>
  
  <p>For example : </p>
  
  <pre><code>In DB i have student table with
   ID,
   Name,
   Class,
   Section
  </code></pre>
  
  <p>And i got id and Name in  <code>ienumerable&lt;student&gt;</code> . From there i need to convert into a <code>DropDown</code></p>