title: DropDownList From Objects MVC
body: <p>Ok so I want make a <code>DropDownList</code> from my object list
  here is my getting object method</p>
  
  <pre><code>public List&lt;Category&gt; GetCategoriesList()
  {
      BaseShopEntities context = new BaseShopEntities();
      List&lt;Category&gt; uniqCategories = (from c in context.Category
                                               select c).Distinct().ToList&lt;Category&gt;();
  
      return uniqCategories;
  }
  </code></pre>
  
  <p>I was trying to put it into the <code>ViewBag</code> like this:</p>
  
  <pre><code>ViewBag.Categories = proxy.GetCategoriesList().ToList();
  </code></pre>
  
  <p>If im taking only names of Categorys and parsing it to string there is no problem but I need ID too</p>
  
  <p>I Want get data like this but don't know how</p>
  
  <pre><code>@Html.DropDownList("CategoryID", new SelectList(ViewBag.Categories.Name));
  </code></pre>