예제 #1
0
        /// <summary>
        /// 见NodeTree.ascx
        /// </summary>
        public static string ConverForTree(DataTable dt, TreeConfig config)
        {
            string ulHtml = "<ul class='tvNav'><li><a class='list1' id='a0' href='" + config.url + "' target='" + config.target + "' ><span class='list_span'>" + config.allText + "</span> <i class='zi zi_thlarge'></i></a>{html}</li></ul>";

            config.hasChild = config.hasChild.Replace("{url}", config.url);
            config.noChild  = config.noChild.Replace("{url}", config.url);
            return(ulHtml.Replace("{html}", ConverForTree_LI(dt, 0, config)));
        }
예제 #2
0
        private static string ConverForTree_LI(DataTable dt, int pid, TreeConfig config)
        {
            string result = "";

            DataRow[] dr = dt.Select("ParentID='" + pid + "'");
            for (int i = 0; i < dr.Length; i++)
            {
                result += "<li>";
                if (dt.Select("ParentID='" + Convert.ToInt32(dr[i]["NodeID"]) + "'").Length > 0)
                {
                    result += string.Format(config.hasChild, dr[i]["NodeID"], dr[i]["NodeName"]);
                    result += "<ul class='tvNav tvNav_ul' style='display:none;'>" + ConverForTree_LI(dt, Convert.ToInt32(dr[i]["NodeID"]), config) + "</ul>";
                }
                else
                {
                    result += string.Format(config.noChild, dr[i]["NodeID"], dr[i]["NodeName"]);
                }
                result += "</li>";
            }
            return(result);
        }