Posts Tagged ‘folder structure’

In my last SharePoint project, the requirement was to bind the folder structure of a document library to a tree view control. There are couple of blog’s available on the web, which talk about looping through folders and files recursively of a document library and adding them one after the other to the tree node of a tree view control. I think this is a costly affair. Instead the better solution would have been to get the results from the document library at one go in the form of a data table or a data set and bind them directly to the tree view control. This approach is not straight forward but is not a costly affair unlike the previous approach.

So the question is how do we achieve this? Below is the list of step’s to achieve the above requirement.

  • CAML query to get all the folders in a document library.
  • Convert the structured data table into hierarchical data table. I couldn’t have completed what I wanted to without referring this post http://www.codeproject.com/KB/webforms/aspnettreeviewbind.aspx.
  • Binding the tree view control to the converted hierarchical data table.

Read Full Post »