public JsonResult GetProjects(string sidx, string sord, int page, int rows) //Gets the todo Lists. { #region MyRegion int pageIndex = Convert.ToInt32(page) - 1; int pageSize = rows; // FinanceToolEntities2 db = new FinanceToolEntities2(); var ProjectResults = db.Usp_GetProjectMasterDetails().Select( project => new { project.ProjectID, project.OpportunityName, project.ProjectName, project.poavilable, project.pobalance, project.SOWStatus, project.Note, project.Createdby, project.Createddate, project.Modifiedby, project.ModifiedDate, project.ProjectCode }).ToList(); int totalRecords = ProjectResults.Count(); var totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows); var customerResults2 = ProjectResults.OrderByDescending(s => s.ProjectName); var customerResults3 = customerResults2.Skip(pageIndex * pageSize).Take(pageSize); var jsonData = new { total = totalPages, page, records = totalRecords, rows = customerResults3 }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); #endregion }