1.数据库设计
[Table("userInfo")] public class UserInfo { [Key] public int Id { get; set; } [Required] [Index(IsUnique =true)] public string Username { get; set; } [Required] public string Password { get; set; } public string Acceuss { get; set; } public string Mobile { get; set; } public string Tel { get; set; } }
2.HTML
*先导入easyUI必须的文件
<ul id="tt" class="easyui-tree" url="/User/TreeGetAccData"></ul>
3.获取数据
public ActionResult TreeGetAccData() { int id = Convert.ToInt32(Request.Form["id"]); //查找parentID=id的节点 var accesses = from a in db.Accesses where a.ParentAccessId == id select a; List<object> list = new List<object>(); foreach(var a in accesses) { list.Add(new { id = a.Id, text = a.Text, state = a.State, url = a.Url }); } return Json(list); }