C# asp.net mvc中的搜索方法
您好,我想使用dropdownlist在我的数据库中进行搜索 就是这样: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
@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()){你以为你是我的朋友吗