[英]Filter from two tables in ASP.NET
我使用 asp.net mvc 创建我的项目。
我有学生、小组和小组的表格。
我设计了摸索的页面,所以当用户 select 摸索时,他们是 go 到另一个具有子组(A,B,Z0D61F8370CAD1D412F80B84D143E125Z,等等)的页面
并且当用户 select 任何一个子组时,学生表的数据过滤以显示包括在组和子组中的学生
我的问题是表格或页面中的数据没有显示,但是当我删除它时
Where(e => e.GroupId == id);
数据显示但组表没有过滤所以所有组显示
这是我在学生中的 controller:
public ActionResult Index(int? id)
{
var students = db.Students.AsQueryable().Include(s => s.Groups).Include(s => s.Subgroups).Include(s => s.Schedules).Include(s => s.Teachers);
if (id != null) students = students.Where(c => c.SubgroupId == id).Where(e => e.GroupId == id);
ViewBag.result = students;
return View(students.ToList()); }
这是我在子组中的观点:
<td>
@Html.ActionLink("students", "Index", "Students", new { id = item.Id }, null)
</td>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.