首页 > 程序开发 > 软件开发 > C# >

用递归方法把资料绑定到TreeView控件,显示文档目录

2010-07-11

using System.Collections.Generic; using System.Reflection; using System.Data;  partial class ViewFolder: System.Web.UI.Page     {   &nb

using System.Collections.Generic;
using System.Reflection;
using System.Data;
partial class ViewFolder: System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
GetNotes();
}
}

private void GetNotes()
{
//根节点
TreeNode tn=new TreeNode("我的文档", "0", this.ControlPath + "images/folder0.gif");
int FolderControlID = DocumentController.GetTabId(this.PortalId, "ViewDocument");
tn.NavigateUrl
= Globals.NavigateURL(FolderControlID, "", "FolderId=0");
TreeFolder.Nodes.Add(tn);

DataTable dt
=null;
try
{
dt
= DocumentController.GetListFolder(UserId);
}

catch (Exception exc)
{
//Module failed to load
Exceptions.ProcessModuleLoadException(this, exc);
}
//增加子节点
IntiTree(TreeFolder.Nodes , dt, 0);

TreeNode dustbin
= new TreeNode("垃圾箱", "-1");
dustbin.ImageUrl
= this.ControlPath + "images/Dustbin.gif

热点推荐