0

ユーザーがインデックスビューをサポートできるようにするこのアクションリンクがあります。

@Html.ActionLink("Opened Date", "Index", new {sortOrder= ViewBag.OpenedDateParm, currentFilter=ViewBag.CurrentFilter})

これは、コントローラーで処理されます

ViewBag.OpenedDateParm = sortOrder == "Date" ? "OpenedDate desc" : "Date";

現在の並べ替えがdescの場合、およびその逆の場合は、ascを並べ替えたいと思います。アクションリンクの状態を評価するために?:を使用しますか?

4

1 に答える 1

2

これをコントローラーアクションに含めます。ViewBag.OpenedDateParmをasc、現在の値がdescである場合とその逆の場合に設定します。

 ViewBag.OpenedDateParm = sortOrder == "asc" ? "desc" : "asc";

あなたの見解では、

 @Html.ActionLink("Opened Date", "Index","YourControllerName",
           new { sortOrder = ViewBag.OpenedDateParm,
                 currentFilter = ViewBag.CurrentFilter },null)
于 2012-07-23T17:17:13.840 に答える