Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# asp.net mvc中的搜索方法_C#_Asp.net Mvc_Razor - Fatal编程技术网

C# asp.net mvc中的搜索方法

C# asp.net mvc中的搜索方法,c#,asp.net-mvc,razor,C#,Asp.net Mvc,Razor,您好,我想使用dropdownlist在我的数据库中进行搜索 就是这样: @Html.DropDownList("Id", new List<SelectListItem>{ new SelectListItem {Text="Agent name",Value="1"}, new SelectListItem {Text="Location",Value= "2",} }, "choose",new { @class = "dr

您好,我想使用dropdownlist在我的数据库中进行搜索

就是这样:

     @Html.DropDownList("Id", new List<SelectListItem>{
      new SelectListItem {Text="Agent name",Value="1"},
       new SelectListItem {Text="Location",Value= "2",}
         }, "choose",new { @class = "dropdown" })

       <input type="submit" class="submit" value="Search" />
当用户选择位置时,数据将按位置排序


问题是,当我尝试单击搜索按钮时,什么都没有发生(就像值为null)

您需要添加表单元素。没有表单元素,将不会提交任何内容

<form action="/Home/Index" method="get">
  @Html.DropDownList("Id", new List<SelectListItem>{
  new SelectListItem {Text="Agent name",Value="1"},
   new SelectListItem {Text="Location",Value= "2",}
     }, "choose",new { @class = "dropdown" })

   <input type="submit" class="submit" value="Search" />
</form>

@Html.DropDownList(“Id”),新列表{
新建SelectListItem{Text=“Agent name”,Value=“1”},
新建SelectListItem{Text=“Location”,Value=“2”,}
},“选择”,新建{@class=“dropdown”})
或使用剃须刀:

@using (Html.BeginForm("Index", "Home", FormMethod.Get))
{
    @Html.DropDownList("Id", new List<SelectListItem>
    {
    new SelectListItem {Text="Agent name",Value="1"},
    new SelectListItem {Text="Location",Value= "2",}
    }, "choose", new { @class = "dropdown" })

    <input type="submit" class="submit" value="Search" />
}
@使用(Html.BeginForm(“Index”,“Home”,FormMethod.Get))
{
@Html.DropDownList(“Id”),新列表
{
新建SelectListItem{Text=“Agent name”,Value=“1”},
新建SelectListItem{Text=“Location”,Value=“2”,}
},“选择”,新建{@class=“dropdown”})
}

您需要添加表单元素。没有表单元素,将不会提交任何内容

<form action="/Home/Index" method="get">
  @Html.DropDownList("Id", new List<SelectListItem>{
  new SelectListItem {Text="Agent name",Value="1"},
   new SelectListItem {Text="Location",Value= "2",}
     }, "choose",new { @class = "dropdown" })

   <input type="submit" class="submit" value="Search" />
</form>

@Html.DropDownList(“Id”),新列表{
新建SelectListItem{Text=“Agent name”,Value=“1”},
新建SelectListItem{Text=“Location”,Value=“2”,}
},“选择”,新建{@class=“dropdown”})
或使用剃须刀:

@using (Html.BeginForm("Index", "Home", FormMethod.Get))
{
    @Html.DropDownList("Id", new List<SelectListItem>
    {
    new SelectListItem {Text="Agent name",Value="1"},
    new SelectListItem {Text="Location",Value= "2",}
    }, "choose", new { @class = "dropdown" })

    <input type="submit" class="submit" value="Search" />
}
@使用(Html.BeginForm(“Index”,“Home”,FormMethod.Get))
{
@Html.DropDownList(“Id”),新列表
{
新建SelectListItem{Text=“Agent name”,Value=“1”},
新建SelectListItem{Text=“Location”,Value=“2”,}
},“选择”,新建{@class=“dropdown”})
}

您需要添加表单元素。没有表单元素,将不会提交任何内容

<form action="/Home/Index" method="get">
  @Html.DropDownList("Id", new List<SelectListItem>{
  new SelectListItem {Text="Agent name",Value="1"},
   new SelectListItem {Text="Location",Value= "2",}
     }, "choose",new { @class = "dropdown" })

   <input type="submit" class="submit" value="Search" />
</form>

@Html.DropDownList(“Id”),新列表{
新建SelectListItem{Text=“Agent name”,Value=“1”},
新建SelectListItem{Text=“Location”,Value=“2”,}
},“选择”,新建{@class=“dropdown”})
或使用剃须刀:

@using (Html.BeginForm("Index", "Home", FormMethod.Get))
{
    @Html.DropDownList("Id", new List<SelectListItem>
    {
    new SelectListItem {Text="Agent name",Value="1"},
    new SelectListItem {Text="Location",Value= "2",}
    }, "choose", new { @class = "dropdown" })

    <input type="submit" class="submit" value="Search" />
}
@使用(Html.BeginForm(“Index”,“Home”,FormMethod.Get))
{
@Html.DropDownList(“Id”),新列表
{
新建SelectListItem{Text=“Agent name”,Value=“1”},
新建SelectListItem{Text=“Location”,Value=“2”,}
},“选择”,新建{@class=“dropdown”})
}

您需要添加表单元素。没有表单元素,将不会提交任何内容

<form action="/Home/Index" method="get">
  @Html.DropDownList("Id", new List<SelectListItem>{
  new SelectListItem {Text="Agent name",Value="1"},
   new SelectListItem {Text="Location",Value= "2",}
     }, "choose",new { @class = "dropdown" })

   <input type="submit" class="submit" value="Search" />
</form>

@Html.DropDownList(“Id”),新列表{
新建SelectListItem{Text=“Agent name”,Value=“1”},
新建SelectListItem{Text=“Location”,Value=“2”,}
},“选择”,新建{@class=“dropdown”})
或使用剃须刀:

@using (Html.BeginForm("Index", "Home", FormMethod.Get))
{
    @Html.DropDownList("Id", new List<SelectListItem>
    {
    new SelectListItem {Text="Agent name",Value="1"},
    new SelectListItem {Text="Location",Value= "2",}
    }, "choose", new { @class = "dropdown" })

    <input type="submit" class="submit" value="Search" />
}
@使用(Html.BeginForm(“Index”,“Home”,FormMethod.Get))
{
@Html.DropDownList(“Id”),新列表
{
新建SelectListItem{Text=“Agent name”,Value=“1”},
新建SelectListItem{Text=“Location”,Value=“2”,}
},“选择”,新建{@class=“dropdown”})
}

即使我想添加一个httppost方法,也不会发生任何事情即使我想添加一个httppost方法,也不会发生任何事情即使我想添加一个httppost方法,也不会发生任何事情哇!!!我忘了添加………@using(Html.BeginForm()){想你是我的朋友!!!我忘了添加………@using(Html.BeginForm()){想你是我的朋友!!!我忘了添加………@using(Html.BeginForm()){想你是我的朋友!!!我忘了添加………@using(Html.BeginForm()){你以为你是我的朋友吗