| |||||
TreeView ClassSystem.Web.UI.WebControls Namespace .NET Framework version 2.0 Displays hierarchical data, such as a table of contents, in a tree structure.
RemarksThe TreeView control is used to display hierarchical data, such as a table of contents or file directory, in a tree structure and supports the following features:
NodesThe TreeView control is made up of nodes. Each entry in the tree is called a node and is represented by a TreeNode object. Node types are defined as follows:
A node can be both a parent and a child, but root, parent, and leaf nodes are mutually exclusive. Several visual and behavioral properties of nodes are determined by whether a node is a root, parent, or leaf node. Although a typical tree structure has only one root node, the TreeView control allows you to add multiple root nodes to your tree structure. This is useful when you want to display item listings without displaying a single root node, as in a list of product categories. Each node has a Text property and a Value property. The value of the Text property is displayed in the TreeView, while the Value property is used to store any additional data about the node, such as data that is passed to the postback event that is associated with the node. A node can be in one of two modes: selection mode and navigation mode. By default, a node is in selection mode. To put a node into navigation mode, set the NavigateUrl property for the node to a value other than an empty string ( "" ). To put a node into selection mode, set the NavigateUrl property for the node to an empty string ( "" ). Static DataThe simplest data model of the TreeView control is static data. To display static data using declarative syntax, first nest opening and closing <Nodes> tags between the opening and closing tags of the TreeView control. Next, create the tree structure by nesting <asp:TreeNode> elements between the opening and closing <Nodes> tags. Each <asp:TreeNode> element represents a node in the tree and maps to a TreeNode object. You can set the properties of each node by setting the attributes of its <asp:TreeNode> element. To create child nodes, nest additional <asp:TreeNode> elements between the opening and closing <asp:TreeNode> tags of the parent node. Binding to DataThe TreeView control can also be bound to data. You can use either of two methods to bind the TreeView control to the appropriate data source type:
When binding to a data source where each data item contains multiple properties ( such as an XML element with several attributes ), a node displays the value that is returned by the ToString method of the data item, by default. In the case of an XML element, the node displays the element name, which shows the underlying structure of the tree but is not very useful otherwise. You can bind a node to a specific data item property by specifying tree node bindings using the DataBindings collection. The DataBindings collection contains TreeNodeBinding objects that define the relationship between a data item and the node that it is binding to. You can specify the criteria for binding and the data item property to display in the node. For more information on tree node bindings, see TreeNodeBinding.
Dynamic Node PopulationThere are cases where it is not practical to statically define the tree structure because the data source returns too much data or because the data to display depends on information that you get at run time. For these cases, the TreeView control supports dynamic node population. When the PopulateOnDemand property for a node is set to true, that node gets populated at run time when the node is expanded. To populate a node dynamically, you must define an event-handling method that contains the logic to populate a node for the TreeNodePopulate event. Microsoft Internet Explorer version 5.0 and later and Netscape 6.0 and later can also take advantage of client-side node population. Client-side node population enables the TreeView control to populate a node using client script when users expand the node, without requiring a round trip to the server. For more information on client-side node population, see PopulateNodesFromClient. For examples illustrating use of this control, see the individual member types of this class. For syntax information, see TreeView in ASP.NET Syntax for Web Controls. See AlsoASP.NET Navigation Controls TreeView Web Server Control |
| ||||
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note
You can help support aspxtreme