protected void Page_Load(object sender, EventArgs e)
        {
            Common.HasLogin();
          
            if (!IsPostBack)
            {
                treebuild();
                
            }
        }
        private void treebuild()
        { 
            tyhgl003BLL modulbll = new tyhgl003BLL();
            IList list = modulbll.GetAllModule();
            //Response.Write(list.Count);
            for (int i = 0; i < list.Count; i++)
            {
                tyhgl003 modual = (tyhgl003)list[i];
                TreeNode tn = new TreeNode();
                tn.Text = modual.cmkmc;
                tn.Value = "0";
                tn.NavigateUrl = "#";
                TreeView1.Nodes.Add(tn);
                
                subtreeNode(tn,modual.cmkdm);
                
            }
        }
        private void subtreeNode(TreeNode ptn,string mkdm)
        {
            
            tyhgl004BLL Cmodualbll = new tyhgl004BLL();
            int count = Cmodualbll.GetChildModualCount(mkdm);
            int tempcount = 0;
            IList listsub = Cmodualbll.GetChildModualByUser(mkdm,hidUser.Value.Trim());
           // IList listsub = Cmodualbll.GetChildModual(mkdm);
           // bool IsCheckedParentNode = false;            for (int j = 0; j < listsub.Count; j++)
            {
                tyhgl004 cmodual = (tyhgl004)listsub[j];
                TreeNode tn = new TreeNode();
                tn.Text = cmodual.ccxmc;
                tn.Value = cmodual.ccxdm;
                tn.NavigateUrl = "#";
                if (cmodual.cqx == "1")
                {
                    tempcount++;
                    tn.Checked = true;
                    ListBox1.Items.Add(new ListItem(tn.Text, tn.Value));
                }
                ptn.ChildNodes.Add(tn);
            }
            if ((tempcount > 0) && (tempcount == count))
                ptn.Checked = true;
        }treebuild()函数运行了两次,有谁遇到过这问题,请指教

解决方案 »

  1.   

    我怎么感觉不是加载了2次,而是treebuild()的问题。其实测试方法很简单,你就在treebuild()中写个write,你看是不是写了2次了?
      

  2.   

    TreeView控件里有个属性ExpandDepth加载时会展开多少层,我感觉你设置展几层就会执行几次PAGE_LOAD
      

  3.   

    页面上有没有一些没有地址的图片,这会导致pageload运行两次
    http://www.cnblogs.com/66feifei/archive/2008/03/01/705721.html
      

  4.   

    谢谢诸位的关注,我用response.write发现page_load运行了两次