Download demo application - 6.00 KB
In my last blog Binding a TreeView control to a hierarchical data structure, Part I, I had describe how one can bind a TreeView control to a hierarchical data structure through recursion. Now I’m going to describe how you can bind a TreeView control to a hierarchical data structure on demand. Basically this technique is useful for very long complex hierarchical data structure.
Simply drag and Drop a TreeView control and handle its OnTreeNodePopulate event.
Target Hierarchical Data
Target hierarchical data that I've chosen for this demo is a folder's hierarchical structure.
Binding TreeView Control
The TreeView control for this demo has been bind in the Page_Load event through the BindTreeView method as-
In this method a TreeView node for the top root folder of given folder hierarchical structure has been created with the help of GetNode method.
This method is simply used to create a TreeView node. Each TreeView node created by this method takes folder name as a Text, folder's fully qualified path as a Value and a folder image. It takes DirectoryInfo as an argument.
Whenever any TreeView node is expanded first time, then this event gets fired. Note that this request is handled through an AJAX call by ASP.NET itself implicitly. Here all the immediate child nodes are attached ot its parent node. On subsequent expansion of that particular parent node, this event isn't gets fired. Simply all the child nodes are fetched from the cache.
You can bind TreeView control to a database hierarchical data source in a similar manner. Do let me know if you have any query or problem.
You may need to change the package name for your android application due to various reasons ranging from a small typo to duplicate domain name. Changing the package name ...
by: Ravi Rawal
If you are looking for dynamically adding different types of "Widgets" into your screen programatically and are also interested in placing them such that many items are v...
This blog teaches you to display line numbers in visual studio text editor.
by: Yukti Arora
This blog teaches you to switch themes in visual studio.
This blog will apply to those folks who use Photoshop for design. I will focus on the use of channels to make a perfect selection out of a very complex image. In this blo...
by: Atul Ahuja
Toast message is a way to provide some information to the user that stays on the screen for a couple of seconds. Here, we will be working on how to beautify that message ...
What kind of email newsletter would you prefer to receive from CodeAsp.Net?