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

C# 将JsonResult绑定到asp net mvc 5中的下拉列表?,c#,asp.net-mvc,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> }

我在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 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
{
公共int a{get;set;}
公共int b{get;set;}
公共int c{get;set;}
公共字符串名称{get;set;}
公共字符串类型{get;set;}
公共int ID{get;set;}
公共类ABCDBContext:DbContext
{
公共数据库集ABC{get;set;}
}
}

那么,为了用ABC拥有的数据类型填充下拉列表,我需要做些什么呢?

你是在使用Ajax获取下拉列表值吗?@Dawood Awan不,不是真的为什么?那么,在表单中以字典的形式将数据发布到视图模型中,我不认为在不回传获取数据的情况下使用JSON有什么意义,您正在加载页面上创建下拉列表,这里没有任何意义。您在哪里调用公共JsonResult Getdata(字符串搜索)?什么是
@Html.DropDownList(“SearchString”)
绑定到的?在何处创建
选择列表
?您需要发布生成视图的controller GET方法
 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; }
    }
}