public JsonResult GetSDUs(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(); LOB oB = new LOB(); var SduResults = db.Usp_GetSDUMasterDetails().Select( sdu => new { sdu.SDUID, sdu.SDUName, sdu.LOBName, sdu.Modifiedby, sdu.Createdby, sdu.ModifiedDate, sdu.Createddate }).ToList(); int totalRecords = SduResults.Count(); var totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows); var customerResults2 = SduResults.OrderByDescending(s => s.SDUName); var customerResults3 = customerResults2.Skip(pageIndex * pageSize).Take(pageSize); var jsonData = new { total = totalPages, page, records = totalRecords, rows = customerResults3 }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); #endregion }