Hi Team
I am returning an empty record list on my dataTable, what could be an issue? Is the issue on my calling of dbContext not correcttly? Please help me mates as i am returning an empty record list on UI. Here is my logic below for this reason.
- [HttpPost]
- public ActionResult GetList() {
- //Server side Parameter.
- int start = Convert.ToInt32(Request["start"]);
- int length = Convert.ToInt32(Request["length"]);
- string searchValue = Request["search[value]"];
- string sortColumnName = Request["columns[" + Request["order[0][column]"] + "][name]"];
- string sortDirection = Request["order[0][dir]"];
- using(eNtsaOnlineRegistrationDBContext db = new eNtsaOnlineRegistrationDBContext()) {
- IQueryable < TblEventsManagements > empList = db.TblEventsManagements;
- int totalrows = empList.Count();
- int totalrowsafterfiltering = totalrows;
- if (!string.IsNullOrEmpty(searchValue)) {
- empList = empList.Where(x => x.TrainingType.Contains(searchValue) || x.TrainingDescription.Contains(searchValue) || x.Price.ToString().Contains(searchValue.ToLower()) ||
- x.Venue.Contains(searchValue) || x.Facilitator.Contains(searchValue) || x.WhoAttend.Contains(searchValue) || x.Rsvp.Contains(searchValue));
- totalrowsafterfiltering = empList.Count();
- }
- empList = empList.OrderBy(sortColumnName + " " + sortDirection).Skip(start).Take(length);
- return Json(new {
- data = empList.ToList(), draw = Request["draw"], recordsTotal = totalrows, recordsFiltered = totalrowsafterfiltering
- }, JsonRequestBehavior.AllowGet);
- }
- }

Asma KhalidRank #160 · 14.7K reputationPosted Feb 13, 2020, 8:12 PM EST
Salman BegRank #284 · 8.8K reputationPosted Feb 12, 2020, 8:00 PM EST
Guest UserRank #877 · 2.5K reputationPosted Feb 12, 2020, 8:11 PM EST
Asma KhalidRank #160 · 14.7K reputationPosted Feb 12, 2020, 8:27 PM EST
Guest UserRank #877 · 2.5K reputationPosted Feb 12, 2020, 8:47 PM EST
Asma KhalidRank #160 · 14.7K reputationPosted Feb 12, 2020, 11:22 PM EST
Guest UserRank #877 · 2.5K reputationPosted Feb 13, 2020, 12:11 AM EST
Guest UserRank #877 · 2.5K reputationPosted Feb 13, 2020, 9:05 PM EST
Ecco SuprastyoRank #1,001 · 2K reputationPosted Feb 13, 2020, 9:54 PM EST