private IList<Model.Menus> ModelParent(DataTable dt, int parentid, IList<Model.Menus> ddl, string str) { string str_; string slt; slt = string.Format("parentid={0}", parentid); DataRow[] drarr = dt.Select(slt); foreach (DataRow dr in drarr) { if (parentid == 0) { str_ = ""; } else { str_ = "├"; } Model.Menus model=new Model.Menus(); if (dr["MenuID"] != null && dr["MenuID"].ToString() != "") { model.MenuID = int.Parse(dr["MenuID"].ToString()); } if (dr["RankID"] != null) { model.RankID = dr["RankID"].ToString(); } if (dr["TypeID"] != null && dr["TypeID"].ToString() != "") { model.TypeID = int.Parse(dr["TypeID"].ToString()); } if (dr["MenuName"] != null) { model.MenuName = str + str_ + dr["MenuName"].ToString(); } if (dr["ParentID"] != null && dr["ParentID"].ToString() != "") { model.ParentID = int.Parse(dr["ParentID"].ToString()); } if (dr["ParentPath"] != null) { model.ParentPath = dr["ParentPath"].ToString(); } if (dr["MenuDepth"] != null && dr["MenuDepth"].ToString() != "") { model.MenuDepth = int.Parse(dr["MenuDepth"].ToString()); } if (dr["PrevID"] != null && dr["PrevID"].ToString() != "") { model.PrevID = int.Parse(dr["PrevID"].ToString()); } if (dr["NextID"] != null && dr["NextID"].ToString() != "") { model.NextID = int.Parse(dr["NextID"].ToString()); } if (dr["OrderID"] != null && dr["OrderID"].ToString() != "") { model.OrderID = int.Parse(dr["OrderID"].ToString()); } if (dr["ChildCount"] != null && dr["ChildCount"].ToString() != "") { model.ChildCount = int.Parse(dr["ChildCount"].ToString()); } if (dr["MenuNewsCount"] != null && dr["MenuNewsCount"].ToString() != "") { model.MenuNewsCount = int.Parse(dr["MenuNewsCount"].ToString()); } if (dr["Content"] != null) { model.Content = dr["Content"].ToString(); } if (dr["Visible"] != null && dr["Visible"].ToString() != "") { if ((dr["Visible"].ToString() == "1") || (dr["Visible"].ToString().ToLower() == "true")) { model.Visible = true; } else { model.Visible = false; } } if (dr["ViewAmount"] != null && dr["ViewAmount"].ToString() != "") { model.ViewAmount = int.Parse(dr["ViewAmount"].ToString()); } if (dr["LinkAddr"] != null) { model.LinkAddr = dr["LinkAddr"].ToString(); } if (dr["Template"] != null && dr["Template"].ToString() != "") { model.Template = int.Parse(dr["Template"].ToString()); } int parent_id = Convert.ToInt32(model.MenuID); ddl.Add(model); ModelParent(dt, parent_id, ddl, str + ".."); } return ddl; }