public ActionResult TicketViewGrid(jQueryDataTableParamModel param) { List <TicketModel> listdetails = new List <TicketModel>(); try { if (TempData.Peek("TicketList") == null) { listdetails = objgetTicket.getAllTableDetails(Convert.ToInt32(Session["LoginID"])); TempData["TicketList"] = listdetails; } else { listdetails = TempData.Peek("TicketList") as List <TicketModel>; } IEnumerable <TicketModel> filteredItems; if (!string.IsNullOrEmpty(param.sSearch)) { var isRetSearchable = Convert.ToBoolean(Request["bSearchable_1"]); var isStoreInvSearchable = Convert.ToBoolean(Request["bSearchable_2"]); var isFromStoreSearchable = Convert.ToBoolean(Request["bSearchable_2"]); filteredItems = listdetails .Where(c => isRetSearchable && c.TicketNo.ToLower().Contains(param.sSearch.ToLower())); } else { filteredItems = listdetails; } var isRetSortable = Convert.ToBoolean(Request["bSortable_1"]); var isStoreInvSortable = Convert.ToBoolean(Request["bSortable_2"]); var isFromStoreSortable = Convert.ToBoolean(Request["bSortable_3"]); var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]); Func <TicketModel, string> orderingFunction = (c => sortColumnIndex == 2 && isRetSortable ? c.TicketNo : ""); var sortDirection = Request["sSortDir_0"]; // asc or desc if (sortDirection == "asc") { filteredItems = filteredItems.OrderBy(orderingFunction); } else { filteredItems = filteredItems.OrderByDescending(orderingFunction); } //var temp= filteredItems.Select(m=>m.) var displayedCompanies = filteredItems.Skip(param.iDisplayStart).Take(param.iDisplayLength); var result = from c in displayedCompanies select new[] { Convert.ToString(c.TicketID), c.TicketNo, c.Type, c.Description, c.Raised_Date, c.Status }; return(Json(new { sEcho = param.sEcho, iTotalRecords = listdetails.Count(), iTotalDisplayRecords = filteredItems.Count(), aaData = result, }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { log.Error(ex); return(Json("Something went wrong..Try after some Time", JsonRequestBehavior.AllowGet)); } }