title: There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'SubGoods'
body: <p>I'm new in <code>asp.net mvc</code> I try this code in below for show fetched items from DB in <code>dropdownlist</code>, but I got this Error :</p>
  
  <pre><code>There is no ViewData item of type 'IEnumerable&lt;SelectListItem&gt;' that has the key 'SubGoods'.
  </code></pre>
  
  <p>Action controller</p>
  
  <pre><code>[HttpGet]
      public ActionResult AddSubGood()
      {
          ViewBag.SubGoods = new SelectList(db.MainGoods, "GoodID", "GoodTitle");
          return View();
      }
  </code></pre>
  
  <p>I try this :</p>
  
  <pre><code>&lt;div class="form-group"&gt;
          @Html.LabelFor(model =&gt; model.FKMainGoodID, new { @class = "control-label col-md-2" })
          &lt;div class="col-md-10"&gt;
              @Html.DropDownList("SubGoods",(IEnumerable&lt;SelectListItem&gt;)ViewBag.SubGoods, "select main good")
              &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>and this :</p>
  
  <pre><code>&lt;div class="form-group"&gt;
          @Html.LabelFor(model =&gt; model.FKMainGoodID, new { @class = "control-label col-md-2" })
          &lt;div class="col-md-10"&gt;
              @Html.DropDownList("SubGoods", "select main good")
              &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>But I got same error.
  Could any one tell me please what's the problem ? </p>