asp.net.ph

TreeView.TreeNodePopulate Event

System.Web.UI.WebControls Namespace   TreeView Class


.NET Framework version 2.0

Occurs when a node with its PopulateOnDemand property set to true is expanded in a TreeView control.

[ VB ]
Public Event TreeNodePopulate As TreeNodeEventHandler

[ C# ]
public event TreeNodeEventHandler TreeNodePopulate;

[ C++ ]
public: __event TreeNodeEventHandler* TreeNodePopulate;

In [ JScript ], you can handle the events defined by a class, but you cannot define your own.

Remarks

The TreeNodePopulate event is raised whenever a node with its PopulateOnDemand property set to true is expanded in a TreeView control.

This allows you to provide an event-handling method that performs a custom routine, such as retrieve node data from a data source, whenever this event occurs.

Event Data

The method assigned to handle the event is passed an argument of type TreeNodeEventArgs object containing data related to this event. The following TreeNodeEventArgs properties provide information specific to this event.

Property Description
Node Gets the node that raised the event.

Remarks

There are cases where it is not practical to statically predefine the tree structure due to data size or custom content that depends on user input. 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, first set the PopulateOnDemand property for the node to true. Next, define an event-handling method for the TreeNodePopulate event that populates the node programmatically.

A typical event-handling method retrieves node data from a data source, places the data into a node structure, and then adds the node structure to the ChildNodes collection of the node being populated. A node structure is created by adding TreeNode objects to the ChildNodes collection of a parent node.

NOTE: When the PopulateOnDemand property for a node is set to true, the node must be populated dynamically. You cannot declaratively nest another node below it; otherwise, an error will occur on the page.

Supported browsers ( Microsoft Internet Explorer version 4.0-compatible browsers and later ) 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, which prevents the need to post back to the server. For more information on client-side node population, see PopulateNodesFromClient.

Example

The following examples demonstrate how to use the TreeNodePopulate event to populate the nodes in the TreeView control dynamically.

Populating TreeView Nodes On Demand
Run Sample | View Source
Populating TreeView Nodes On Demand Using Page Titles
Run Sample | View Source
Populating TreeView Nodes from a Database
Run Sample | View Source
See Also

TreeView Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 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 asp.net.ph