0、数据表结构,主要属性有:Id、parentId(父节Id)、Text、Url……等等。
1、新建一个树结构MenuModels
1 public class MenuModels 2 { 3 private int _id; 4 private string _text; 5 private int? _parentid; 6 private string _icon; 7 private string _url; 8 private object _menus; 9 private Dictionary<string, string> _attributes = new Dictionary<string, string>(); 10 11 public int id 12 { 13 get { return _id; } 14 set { _id = value; } 15 } 16 public int? parentid 17 { 18 get { return _parentid; } 19 set { _parentid = value; } 20 } 21 public string text 22 { 23 get { return _text; } 24 set { _text = value; } 25 } 26 public string icon 27 { 28 get { return _icon; } 29 set { _icon = value; } 30 } 31 public string url 32 { 33 get { return _url; } 34 set { _url = value; } 35 } 36 public Dictionary<string, string> attributes 37 { 38 get { return _attributes; } 39 set { _attributes = value; } 40 } 41 public object menus 42 { 43 get { return _menus; } 44 set { _menus = value; } 45 } 46 }