TreeView无刷新动态生成树[C# Asp.net 2.0]

public partial class AdvAcordTree : System.Web.UI.Page
    {
    SysInfo sysInfo = new SysInfo();
    DES des = new DES();
    string patid;
    DataSet ds; protected void Page_Load(object sender, EventArgs e)
    {
    patid = Request["patid"];
    if (ds == null)
    {
    ds = new AdvAcord().GetMenuTree(sysInfo.ActDeptId, sysInfo.StaffId);
    }
    if (!IsPostBack)
    {
    TreeInit();
    } } /// <summary>
    /// 无刷新动态生成树
    /// </summary>
    private void TreeInit()
    {
    this.Tvtree.Nodes.Clear();
   
    //添加个人模板
    TreeNode node = new TreeNode("本人", "30");
    node.SelectAction = TreeNodeSelectAction.Expand;
    node.PopulateOnDemand = true;
    this.Tvtree.Nodes.Add(node);
   
    //添加本科模板
    node = new TreeNode("本科", "20");
    node.SelectAction = TreeNodeSelectAction.Expand;
    node.PopulateOnDemand = true;
    this.Tvtree.Nodes.Add(node);
   
    //添加全院模板
    node = new TreeNode("全院", "10");
    node.SelectAction = TreeNodeSelectAction.Expand;
    node.PopulateOnDemand = true;
    this.Tvtree.Nodes.Add(node);
    }
   
    public void TreeShow(object sender, TreeNodeEventArgs e)
    {
    if (IsCallback)
    if (e.Node.ChildNodes.Count == 0)
    {
    LoadChildNode(e.Node,int.Parse(e.Node.Value));
    }
    }
   
    private void LoadChildNode(TreeNode node, Int32 id)
    {
    DataView dv = ds.Tables[0].DefaultView;
    dv.RowFilter = string.Format(" sharekd = {0} ", id);
    foreach (DataRowView drv in dv)
    {
    TreeNode nNew = new TreeNode();
    nNew.Text = drv[GRPRCPPData.NAME_FIELD].ToString();
    nNew.NavigateUrl = string.Format("AdvAcord.aspx?patid={0}&;amp;id={1}",
    patid, des.Encrypt(drv[GRPRCPPData.ID_FIELD].ToString()));
    node.ChildNodes.Add(nNew);
    }
    }
    }

 感谢原创者的辛勤劳动,希望对您有所帮助,转载请注明原出处。
 您可能对 [Asp.Net] 的这些文章也感兴趣:

ASP.NET程序中常用的三十三种代码
ASP.NET应用程序规划与设计(2)
ASP.NET Popup Control
Win中Net命令的另类用法
ASP.NET3.5的ListView与CSS Friendly
ASP.NET MVC中使用ASP.NET AJAX异步访问WebService
Asp.net 页面导航的几种方法与比较
如何点击按钮弹出新窗口,输入数据后返回并刷新页面?
ASP.NET创建文件并写入内容
用Response.BinaryWrite写文件流