我试图在actionlink帮助器中包含和viewbag对象。
@Html.ActionLink( "Date" + ViewBag.icon , "Index", new{ sortBy=ViewBag.DateSort})
我的Viewbag的逻辑。
ViewBag.icon = (ViewBag.DateSort == "Date desc") ? "▼" :"▲";
我在这里实施排序。
答案 0 :(得分:1)
只需将DateSort添加到Controller中的ViewBag,然后在View中执行此操作:
@{
var dateHeader = "Date " + (ViewBag.DateSort == "Date desc" ? "▼" : "▲");
}
@Html.ActionLink(dateHeader, "Index", new { sortBy = ViewBag.DateSort })