public ActionResult GetRegisteredDevice(string keyword, int Length, int Start) { string IDUser = Session["IDUser"].ToString(); try { var res = dc.GetDevice(IDUser, keyword, Length, Start); int?TotalRecords; if (res.Count() > 0) { TotalRecords = res.FirstOrDefault().TotalRecords; } else { TotalRecords = 0; } var resutltJson = from d in res select new string[] { d.Device_Name, d.SiteName, d.Category_Name, d.Device_Description, d.mac1, d.mac2, d.mac3, d.Device_ID, d.Device_Site_ID, d.Device_category_ID, d.Username, d.dateentry.Value.ToShortDateString(), d.userlastmaintenance, d.datelastmaintenance.ToShortDateString() == "1900-01-01"?"":d.datelastmaintenance.ToShortDateString() }; return(Json(new { iTotalRecords = TotalRecords, iTotalDisplayRecords = TotalRecords, aaData = resutltJson }, JsonRequestBehavior.AllowGet)); } catch (Exception err) { return(Content(err.ToString())); } }