Instead of statically binding the TreeView control to a site map or XML file, gain flexibility by creating it dynamically during runtime.
In other labs in this chapter, you have seen how the TreeView control can be bound to site map files as well as XML documents at design time. However, you can also build your TreeView control dynamically, one node at a time. For example, you might want to display a particular disk directory using the TreeView control, or you may have a site that is changing frequently and hence it is much more efficient to build the tree dynamically.
In this lab, you will use the TreeView control to display the current application path and its subdirectories.
In this lab, you will learn how to customize the TreeView control and dynamically populate it with items. Specifically, you will display the current application path and all its subdirectories in the TreeView control.
Launch Visual Studio 2005 and create a new ASP.NET 2.0 web application. Name the project C:\ASPNET20\chap02-DynamicTreeView.
Drag and drop a TreeView control onto the default Web Form.
In Solution Explorer, right-click the project name and select Add New Folder→ Regular Folder. Name the folder Images, since you'll use this folder to store your image files.
Add the images shown in Figure 2-36 to the C:\ASPNET20\chap02-DynamicTreeView\Images folder.
The images can be downloaded from this book's support site at http://www.oreilly.com/catalog/aspnetadn/ ...