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.
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 ...
by: Ravi Rawal
Adobe has been keeping busy for a few months now working on the new features for Photoshop CC 2015. And finally they released a new version recently. The engineers worked...
In this blog, we will create a string array in our file "strings.xml" and then bind it to the listview and display some information in another string array based on that ...
Read on to find which new features have been added in Visual Studio 2015
by: Yukti Arora
Here you will be given an introduction on how to read and write to a file saved in internal storage of your phone.
What kind of email newsletter would you prefer to receive from CodeAsp.Net?