public ActionResult Index() { List<SubLIst> nodes = new List<SubLIst>(); dbEntities entities = new dbEntities(); //Loop and add the Parent Nodes. foreach (tblManual type in entities.tblManualLists) { nodes.Add(new SubLIst { id = type.ManualId.ToString(), parent = "#", text = type.Code }); } //Loop and add the Child Nodes. foreach (tblSubManual subType in entities.tblSubManuals) { nodes.Add(new SubLIst { id = subType.ManualId.ToString() + "-" + subType.SubManualId.ToString(), parent = subType.ManualId.ToString(), text = subType.Code }); } //Serialize to JSON string. ViewBag.Json = (new JavaScriptSerializer()).Serialize(nodes); return View(); } [HttpPost] public ActionResult Index(string selectedItems, tblDocument employee) { if (ModelState.IsValid) { List<SubLIst> items = (new JavaScriptSerializer()).Deserialize<List<SubLIst>>(selectedItems); employee.ModifiedDate = DateTime.Now; dc.tblDocuments.Add(employee); dc.SaveChanges(); return RedirectToAction("Index"); } return Json(new { success = true }, JsonRequestBehavior.AllowGet); } }
parent = "#"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)