Asp.net mvc 1视图中的多个液滴列表过滤器
我有一个视图,它有一个过滤器,在更改时过滤视图。我的问题是如何添加第二个水滴列表和第三个水滴列表。我不知道如何开始这个过程。以下是我目前使用1所做的工作Asp.net mvc 1视图中的多个液滴列表过滤器,asp.net-mvc,Asp.net Mvc,我有一个视图,它有一个过滤器,在更改时过滤视图。我的问题是如何添加第二个水滴列表和第三个水滴列表。我不知道如何开始这个过程。以下是我目前使用1所做的工作 Branch: @Html.DropDownList("Branch", ViewBag.Branches as SelectList, "All Locations") 在我的控制器中: 公共操作结果分支(字符串分支) { ViewBag.BranchName=分支 IEnumerable<Employee&
Branch: @Html.DropDownList("Branch", ViewBag.Branches as SelectList, "All Locations")
在我的控制器中:
公共操作结果分支(字符串分支)
{
ViewBag.BranchName=分支
IEnumerable<Employee> employees = from m in db.Employees
where m.Branch == Branch || Branch == null || Branch == ""
select m;
IEnumerable<Branch> branches = from c in bCon.Branches
where c.BranchName == Branch
select c;
var viewModel = new BranchViewModel()
{
BranchName = Branch,
Employees = employees.ToList(),
Branches = branches.ToList()
};
return View(viewModel);
}
IEnumerable employees=从m开始,单位为db.employees
其中m.Branch==Branch | | Branch==null | | Branch==“”
选择m;
IEnumerable branchs=来自bCon.branchs中的c
其中c.BranchName==分支
选择c;
var viewModel=new BranchViewModel()
{
BranchName=分支,
Employees=Employees.ToList(),
Branchs=Branchs.ToList()
};
返回视图(viewModel);
}
问候,,
SEB您只需在razor中使用@Model即可将viewModel发送到View
Branch: @Html.DropDownList("Branch", @Model.Branches as SelectList, "All Locations")
Employees : @Html.DropDownList("Branch", @Model.Employees as SelectList, "All Locations")
Branch: @Html.DropDownList("Branch", @Model.Branches as SelectList, "All Locations")
Employees : @Html.DropDownList("Branch", @Model.Employees as SelectList, "All Locations")