2011-09-12 223 views
0

项目:ASP.NET 3.5,C#树导航显示文件夹结构

我有这么多 - 它用来存放“文件夹” 的表。每个文件夹可能包含子文件夹和文件。所以如果我点击一个文件夹,我必须列出文件夹的内容。

所以,我想告诉他现在在哪里像下面

父文件夹的一些事情用户 - >儿童Folder1中 - >儿童Folder1_1

哪个ASP.NET控件我应该使用吗?我怎样才能完成这项任务?

我认为SiteMapPath是最好的选择。你怎么看 ?

回答

1

希望的文件夹结构可能是一个动态的,所以使用SiteMap控件有些困难。我会建议你手动执行此操作,以维护一个ViewState/SessionState存储变量。

当您更改文件夹时更新变量/属性。

public System.Collections.Generic.List<string> FolderPath 
    { 
     get 
     { 
      if (ViewState["__FolderPath"] == null) 
       ViewState["__FolderPath"] = new System.Collections.Generic.List<string>(); 
      (System.Collections.Generic.List<string>)ViewState["__FolderPath"]; 
     } 
     set 
     { 
      ViewState["__FolderPath"] = value; 
     } 
    } 
    public string CurrentPath 
    { 
     get 
     { 
      //retrun the current path from the List FolderPath. ; 
     } 
    } 
0

您可以用TreeView控件实现这一目标