我正在尝试设置一个页面,让我可以按各种参数进行过滤。过滤器是控制器的可空参数。
例如,我有3个过滤器,A,B和C.我希望有不同的链接,将a,b和c设置为不同的值,同时保持其他值不变。
目前,我这样做:
@{
var routeValues = new RouteValueDictionary(Model.routeValues);
var temp = routeValues["a"];
routeValues["a"] = "1";
@Html.ActionLink("A = 1","Index",routeValues)
routeValues["a"] = "2";
@Html.ActionLink("A = 2","Index",routeValues)
routeValues["a"] = temp
temp = routeValues["b"];
routeValues["b"] = "1";
@Html.ActionLink("B = 1","Index",routeValues)
routeValues["b"] = "2";
@Html.ActionLink("B = 2","Index",routeValues)
routeValues["b"] = temp
temp = routeValues["c"];
routeValues["c"] = "1";
@Html.ActionLink("C = 1","Index",routeValues)
routeValues["c"] = "2";
@Html.ActionLink("C = 2","Index",routeValues)
routeValues["c"] = temp
}
我希望有一种更清洁的方法。
由于