asp.net.ph

TreeNode.Text Property

System.Web.UI.WebControls Namespace   TreeNode Class


.NET Framework version 2.0

Sets or retrieves the text displayed for a TreeNode in a TreeView control.

Syntax


Inline <asp:treenode text = strtext ... >
Script TreeNode.Text [ = strtext ]

Property Value


strtext String that specifies the text displayed for a node in a TreeView control.

The property is read/write with no default value.

Remarks

Use the Text property to specify or determine the text to display for a TreeNode in a TreeView control.

In certain cases, such as when a TreeView control is bound to a data source, the Text property is usually obtained dynamically from the data source.

Example

The following example shows how to declaratively set the Text property of tree nodes at design time.

<asp:treenode text = "News">

 Show me 

The following example shows how to programmatically set the Text property of tree nodes at run time.

TreeNode newNode = new TreeNode ( newNodeText, newNodeValue );
myTreeView.Nodes.Add ( newNode );
  C# VB

 Show me 

The following example demonstrates how to programmatically determine the given Text for a node and its parent, when the user selects an item from a TreeView control.

TreeNode selectedNode = myTreeView.SelectedNode;
message.Text = "Selected TreeNode Text: " + selectedNode.Text;
  C# VB

Note that this example merely serves to illustrate the concept. If all you need is to determine the selected node's Text, simply use the SelectedNode.Text property instead, without having to code a handler for the SelectedNodeChanged event.

 Show me 

See Also

TreeNode Members   Value   SelectedValue 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