The ASP. NET Treeview control allows you to easily respond when a user clicks a node, or change the behavior of a node so that the behavior is similar to that of a hyperlink. In addition, you can use the Treeview control to display check boxes next to each node so that you can select multiple nodes at a time.
1. Selection and navigation
Each node has a text attribute and a value attribute. The value of the text attribute is displayed in the Treeview control, and the value attribute is used to store other data about the node, such as node-related data that is passed to the send-back event.
When you click a node of the Treeview control, a selection event (by sending back) or another page may be triggered. If the navigateurl attribute is not set, clicking a node will trigger the selectednodechanged event, which can be used to provide custom functions. You can also check the selected attribute of a node to determine whether the node has been selected. If this attribute is set to true or the select method is called for the node, the node is selected programmatically.
Each node also has a selectaction attribute that can be used to specify the operations that will occur when a node is clicked, such as expanding or folding a node. To avoid the selectednodechanged event when you click a node, but go to another page, set the navigateurl attribute of the node to a value that is not a null string.
Ii. Check box
If you want to select multiple nodes, you can use the Treeview control to display the check box next to the node image. If you set the showcheckboxes attribute to a treenodetype that is not treenodetype. None, the check box is displayed next to the specified node. When the check box is displayed, you can use the treenodecheckchanged event to run a custom routine when the status of the check box sent to the server changes. When the next page is sent to the server, the checkednodes attribute is filled with the selected node.
The Treeview control does not expose the autopostback attribute. Therefore, to submit the check box selection, you must place a control (such as the button Web Server Control) on the page to send the information back to the server.