将JsonResult绑定到asp net mvc 5的下拉列表中?

时间:2014-12-11 15:33:24

标签: c# asp.net-mvc

我在填写asp.net mvc 5中的下拉列表时遇到问题。所以我在我看来有这个

  @using (Html.BeginForm("Getdata", "Data", FormMethod.Get))
{
<p>
    Choose your type of data: @Html.DropDownList("SearchString") <br />
    <input type="submit" value="Filter" />
</p>

}

这是控制器方法

     public JsonResult Getdata(string search)
    {
        var data = (from m in db.ABC
                          select search).Distinct();

        return Json(data, JsonRequestBehavior.AllowGet);

    }

这就是模型

 public class ABC
{
    public int a { get; set; }
    public int b { get; set; }
    public int c { get; set; }
    public string Name { get; set; }
    public string Type { get; set; }
    public int ID { get; set; }


    public class  ABCDBContext : DbContext
    {
        public DbSet<ABC> ABC { get; set; }
    }
}

那么我需要更改什么来填充ABC具有的数据类型的下拉列表?

0 个答案:

没有答案