asp.net.ph

TreeView.SelectedValue Property

System.Web.UI.WebControls Namespace   TreeView Class


.NET Framework version 2.0

Returns the value of the selected node in a TreeView control.

Syntax


Script [ String strValue = ] TreeView.SelectedValue

This property can only be used programmatically; it cannot be set when declaring the control.

Property Value


strValue The value of the selected node in a TreeView control.

The property is read only with no default value.

Remarks

Use the SelectedValue property to determine the value of the selected node in a TreeView control.

This property simply returns the value of the Value property of the TreeNode object that is referred to by the SelectedNode property ( SelectedNode.Value ).

If no Value is specified for the node, this property returns the value of the selected node's Text property. If the Text property in turn contains a null reference, or if no node is currently selected in the TreeView control, an empty string ( "" ) is returned.

To access other properties of the selected node, though, such as Parent or Depth, you still need to use the SelectedNode property.

Example

The following example demonstrates how to use the SelectedValue property to determine the value of the selected node in a TreeView control.

message.Text = "Selected TreeNode Value: " + myTreeView.SelectedValue;
  C# VB

 Show me 

See Also

TreeView Members   SelectedNode   Text   Value 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