2011-09-12 183 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控件實現這一目標