public ActionResult ListTrack(List <DetailTrackWithArtist> List, int?Page, string sortOrder) { int PageSize = 10; int PageNumber = (Page ?? 1); if (List != null) { return(View(List.ToPagedList(PageNumber, PageSize))); } else { List = DetailTrackDB.ListAll(); ViewBag.TitleSortParm = String.IsNullOrEmpty(sortOrder) ? "TitleDesc" : "Title"; ViewBag.FirstNameSortParm = sortOrder == "FirstName" ? "FirstNameDesc" : "FirstName"; ViewBag.LastNameSortParm = sortOrder == "LastName" ? "LastNameDesc" : "LastName"; ViewBag.DateSortParm = sortOrder == "Date" ? "DateDesc" : "Date"; List = TrackFunctions.OrderListTrack(List, sortOrder); return(View(List.ToPagedList(PageNumber, PageSize))); } }