• 动态加载TreeNode ComponentArt TreeView


           ComponentArt是我所用过的第三方控件中比较优秀的一套。下面代码主要实现树节点的动态加载,比较简单,所以只贴代码:
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ProjectTree.ascx.cs" Inherits="Modules_Other_ProjectTree" %>
    <%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %>
    <ComponentArt:TreeView id="TreeView1" Height="350px" Width="100%" 
        DragAndDropEnabled
    ="false" 
        NodeEditingEnabled
    ="false"
        KeyboardEnabled
    ="true"
        CssClass
    ="TreeView" 
        NodeCssClass
    ="TreeNode" 
        SelectedNodeCssClass
    ="SelectedTreeNode" 
        HoverNodeCssClass
    ="HoverTreeNode"
        NodeEditCssClass
    ="NodeEdit"
        LineImageWidth
    ="19" 
        LineImageHeight
    ="20"
        DefaultImageWidth
    ="16" 
        DefaultImageHeight
    ="16"
        ItemSpacing
    ="0" 
        ImagesBaseUrl
    ="images/"
        NodeLabelPadding
    ="3"
        ShowLines
    ="true" 
        LineImagesFolderUrl
    ="images/lines/"
        EnableViewState
    ="true"
        runat
    ="server" LoadingFeedbackText="Loading " >
      
    </ComponentArt:TreeView>

    protected void Page_Load(object sender, EventArgs e)
        
    {
            
    if (!Page.IsPostBack)
            
    {
                TreeViewNode rootnode 
    = new TreeViewNode();
                rootnode.Text 
    = "项目";
                rootnode.Expanded 
    = true;
                TreeView1.Nodes.Add(rootnode);

                ProjectDB pdb 
    = new ProjectDB();
                IList
    <Project.Model.Project> plist = pdb.ProjectList();
                
    foreach (Project.Model.Project p in plist)
                
    {
                     TreeViewNode pnode 
    = new TreeViewNode();
                    pnode.Text 
    = p.PNO + " " + p.ProjectName;
                    pnode.ID 
    = p.Id.ToString();
                    pnode.Value 
    = "Project";
                    pnode.ContentCallbackUrl 
    = "Test.aspx?Pid=" + p.Id;
                    rootnode.Nodes.Add(pnode);
                }
     
            }
          
        }


    <%@ Page Language="C#" AutoEventWireUp="true" %>
    <%@ import Namespace="System.Threading" %>
    <%@ import Namespace="System.IO" %>
    <%@ Import Namespace="Project.DAO" %>
    <%@ Import Namespace="Project.Model" %>
    <%@ import Namespace="ComponentArt.Web.UI" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    <% Response.ContentType = "text/xml"%>
    <script language="C#" runat="server" type="text/C#">
        
    void Page_Load(Object sender, EventArgs e)
        
    {
            ComponentArt.Web.UI.TreeView TreeView1 
    = new ComponentArt.Web.UI.TreeView();

            ProjectDB pdb 
    = new ProjectDB();
            
    if (Request.QueryString["Pid"!= null && Request.QueryString["Pid"!= "")
            
    {
                
    int pid = int.Parse(Request.QueryString["Pid"]);

                IList
    <ProjectStep> pslist = pdb.GetPstepByPid(pid, 0);
                foreach (ProjectStep ps 
    in pslist)
                
    {
                    TreeViewNode node 
    = new TreeViewNode();

                    node.Text 
    =  ps.StepName;
                    node.ID 
    = ps.Id.ToString();
                    node.Value 
    = "Step";
                    
                    TreeView1.Nodes.Add(node);
                }

            }


            Response.Write(TreeView1.GetXml());
        }

    </script>
  • 相关阅读:
    MCPD 70536题目 自定义打印参数
    《ERP从内部集成起步》读书笔记——第5章 MRP系统的时间概念 5.1 时间三要素 5.1.2 时段
    Jquey拖拽控件Draggable用法
    MCPD 70536题目 反射
    MCPD 70536题目 非托管资源 释放
    VS2008创建Silverlight项目时出错解决方法
    程序猿去旅行
    EntityFramework5.0 数据迁移笔记解决模型变化重建数据库的问题
    完美生活
    一直很安静
  • 原文地址:https://www.cnblogs.com/pw/p/611327.html
Copyright © 2020-2023  润新知