내 두 개의 링크 필터하기 : 필터링ASP.NET MVC ActionLink 유지 "오래된"경로 인수
@Html.ActionLink("Customer 1", "Index", new { customer = 1 })
@Html.ActionLink("Project A", "Index", new { project = "A" })
내 컨트롤러 :
public ViewResult Index(int? customer, int? project) {
var query = ...
if (customer != null) {
query = query.Where(o => o.CustomerID == customer);
}
if (project != null) {
query = query.Where(o => o.ProjectID == project);
}
return View(query.ToList());
}
지금은 고객 또는 프로젝트가 아니라 하나 필터링 할 수 있습니다 동시에 둘 다! 내가 프로젝트을 클릭하면 내가 고객 1 url = Object?customer=1
을 클릭하면
, url = Object?project=a
은 내가 먼저 고객 1을 클릭 할 수 다음 프로젝트 A와 url = Object?customer=1&project=a
을 좀하고 싶습니다
이인가
가능하거나 다른 방식으로해야합니까?감사합니다.
일이 올바른 방법입니다 –