public void Populate(NavFromDB nav, List <string> children) { for (int i = 0; i < children.Count; i++) { int ChildID; if (Int32.TryParse(children[i], out ChildID)) { NavItemFromDB ni = nav.GetNavID(ChildID); if (ni != null) { GlobalMenuItem ChildItem = new GlobalMenuItem(ChildID, ni.Label, ni.LabelID, this.Level + 1, ni.Url); ChildItem.Populate(nav, ni.ChildrenNavIDs); Children.Add(ChildItem); } } } }
private static GlobalMenuItem ProcessMenu(DataTable dt) { NavFromDB nav = new NavFromDB(); for (int r = 0; r < dt.Rows.Count; r++) { NavItemFromDB ni = new NavItemFromDB(); ni.NavID = DBUtil.GetInt(dt.Rows[r], 0); ni.Label = DBUtil.GetString(dt.Rows[r], 1); ni.Icon = Encoding.UTF8.GetBytes(DBUtil.GetString(dt.Rows[r], 2)); ni.SetChildrenNavIDs(DBUtil.GetString(dt.Rows[r], 3)); ni.Type = DBUtil.GetString(dt.Rows[r], 4); ni.Url = DBUtil.GetString(dt.Rows[r], 5); ni.LabelID = DBUtil.GetInt(dt.Rows[r], 6); nav.navs.Add(ni); } GlobalMenuItem root = new GlobalMenuItem(0, "", -1, 0, ""); root.Populate(nav, nav.GetRootChildren("gm-root")); return(root); }