title: How to bind dropdown values from Database through stored procedure in Strongly typed views in MVC..?
body: <p>I have a strongly typed view as shown below:</p>
  
  <pre><code>  &lt;div class="form-group"&gt;
        @Html.LabelFor(model =&gt; model.Text, htmlAttributes: new { @class = "control-label col-md-2" })
           &lt;div class="col-md-10"&gt;
  
               @Html.DropDownListFor(model =&gt; model.Text, "Drop");    @*Error Line*@
  
                 @Html.ValidationMessageFor(model =&gt; model.Text, "", new { @class = "text-danger" })
              &lt;/div&gt;
  </code></pre>
  
  <p>With model Class DropdownCheck like below:</p>
  
  <pre><code> public class DropdownCheck
   {
      public string Text { get; set; }
      public String Test { get; set; }
   }
  </code></pre>
  
  <p>Basically, I don't want to hard-code values to view through list items,but wants to bind it from database through stored procedure.</p>
  
  <p>So, For that I have controller like below</p>
  
  <pre><code>   [HttpGet]
      public ActionResult Dropdown()
      {
          BusDataContext dtnew=new BusDataContext();
          ViewBag.Drop = new SelectList(dtnew.Bind_Dropdown().ToList(), "BusSrlNo", "Name");
          return View();
      }
  </code></pre>
  
  <p>Also storing dropdown id,text in ViewBag as above.
  where Bind_Dropdown() is like below</p>
  
  <pre><code>  public IEnumerable&lt;DropdownValues&gt; Bind_Dropdown()
     {
         var res = dt.Get_Bus_Dropdown().ToList();
         List&lt;DropdownValues&gt; drop = new List&lt;DropdownValues&gt;();
  
         for (var i = 0; i &lt; res.Count; i++)
         {
             DropdownValues name = new DropdownValues();
             name.drpbusid = Convert.ToInt32(res[i].BusSrlNo);
             name.drpbusname = Convert.ToString(res[i].Name);
             drop.Add(name);
         }
         return drop;
     }
  </code></pre>
  
  <p>where DropdownValues is a class like below:</p>
  
  <pre><code>   public class DropdownValues
  {
      public int drpbusid { get; set; }
      public string drpbusname { get; set; }
  }
  </code></pre>
  
  <p>Stored procedure returns dropdown value and Text as BusSrlNo and Name.
  After doing all these stuff,getting error compilation like below:
  : </p>
  
  <blockquote>
    <p>CS1928: 'System.Web.Mvc.HtmlHelper' does not
    contain a definition for 'DropDownListFor' and the best extension
    method overload
    'System.Web.Mvc.Html.SelectExtensions.DropDownListFor(System.Web.Mvc.HtmlHelper,
    System.Linq.Expressions.Expression>,
    System.Collections.Generic.IEnumerable)'
    has some invalid arguments</p>
  </blockquote>