Gets or sets a value indicating whether the node to which the TreeNodeBinding object is applied is populated dynamically.
Assembly: System.Web (in System.Web.dll)
Sometimes, it is not practical to statically predefine the tree structure due to data size or custom content that depends on user input. Because of this, the TreeView control supports dynamic node population. When the property is set to true, the child nodes of the node that the TreeNodeBinding object is applied to gets populated at run time when the node is expanded.
When data bindings are created by setting the AutoGenerateDataBindings of the TreeView control to true, the bindings that are created have the property set to true. Data bindings that are created declaratively have the property set to false. Using the declarative syntax allows you to control the behavior of individual data bindings.
Unlike the PopulateOnDemand property of the TreeNode class, the property does not require an event-handling method to be defined for the TreeNodePopulate event, if you are using a data source control, such as XmlDataSource. Instead, the TreeView control dynamically generates an event-handling method using the properties of the TreeNodeBinding objects in the DataBindings collection. You can still define an event-handling method for the TreeNodePopulate event; however, it will be called after the event-handling method for the TreeView control.
Supported browsers can also take advantage of client-side node population. When enabled, this allows the TreeView control to populate a node dynamically on the client when that node is expanded, preventing the need to post back to the server. For more information on client-side node population, see PopulateNodesFromClient.
The value of this property is stored in view state.
This section contains two code examples. The first code example demonstrates how to use the ShowCheckBox property to specify whether a check box is displayed for a node. The second code example provides sample XML data for the first code example.
The following example demonstrates how to use the ShowCheckBox property to specify whether a check box is displayed for a node. For this example to work correctly, you must copy the sample XML data, provided after this code example, to a file named Book.xml.
The following code example provides sample XML data for the preceding code example.
<Book Title="Book Title"> <Chapter Heading="Chapter 1"> <Section Heading="Section 1"> </Section> <Section Heading="Section 2"> </Section> </Chapter> <Chapter Heading="Chapter 2"> <Section Heading="Section 1"> </Section> </Chapter> <Appendix Heading="Appendix A"> </Appendix> </Book>