public ActionResult getdata(List<UserModel> lst ) { UserModel usermodel = new UserModel(); UserService uservice = new UserService(); //return View(db.VideoModels.OrderByDescending(v => v.VideoId).ToPagedList(page, 3)); string[] columnNames = (string[])TempData["columnname"]; lst = new List<UserModel>(); lst = uservice.GetAllUsers(); JavaScriptSerializer serializer = new JavaScriptSerializer(); List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>(); Dictionary<string, object> row; foreach (var dr in lst) { row = new Dictionary<string, object>(); rows.Add(row); } return Json(serializer.Serialize(lst), JsonRequestBehavior.AllowGet); } public ActionResult GetColumnDetails( List<UserModel> lst) { UserModel usermodel = new UserModel(); UserService uservice = new UserService(); //return View(db.VideoModels.OrderByDescending(v => v.VideoId).ToPagedList(page, 3)); lst = new List<UserModel>(); lst = uservice.GetAllUsers(); // id = (int)Session["id"] ; // dt = GetTableDetails(id); //string[] columnNames = lst. // Select(x => x.) // .ToArray(); //string[] columnNames = (from ss in lst.GetType().GetProperties() select ss.Name).ToArray(); //string colNames = string.Empty; var listOfStrings = new List<string>(); // do stuff... string[] colNames = listOfStrings.ToArray(); string[] columnNames = (from t in typeof(PrTblUsers).GetProperties() select t.Name).ToArray(); JavaScriptSerializer serializer = new JavaScriptSerializer(); return Json(serializer.Serialize(colNames= columnNames), JsonRequestBehavior.AllowGet); }t); }