This documentation is archived and is not being maintained.

TreeNodeBinding.SelectAction Property

Gets or sets the event or events to raise when a node to which the TreeNodeBinding object is applied is selected.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public TreeNodeSelectAction SelectAction { get; set; }

Property Value

Type: System.Web.UI.WebControls.TreeNodeSelectAction
One of the TreeNodeSelectAction values. The default is TreeNodeSelectAction.Select.

When the TreeView control is bound to a data source, use the SelectAction property to specify the value to bind to the SelectAction property of a TreeNode object. This binding relationship affects all TreeNode objects to which the TreeNodeBinding object is applied. The SelectAction property is used to specify which event or events are raised when a node is selected.


You can selectively override the SelectAction property by setting the SelectAction property of each node directly.

The following table lists the available options.

SelectAction value



Toggles the node between expanded and collapsed. Raises the TreeNodeExpanded event or the TreeNodeCollapsed event, as appropriate.


Raises no events when a node is selected.


Raises the SelectedNodeChanged event when a node is selected.


Raises both the SelectedNodeChanged and TreeNodeExpanded events when a node is selected. Nodes are only expanded, never collapsed.


The HoverNodeStyle is not rendered for a node with its SelectAction property set to TreeNodeSelectAction.None.

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 SelectAction property to specify which event is raised when a node is clicked. The second code example provides sample XML data for the first code example.

The following example demonstrates how to use the SelectAction property to specify which event is raised when a node is clicked. For this example to work correctly, you must copy the sample XML data, provided after this code example, to a file named Book.xml.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<script runat="server">

  void Node_Changed(Object sender, EventArgs e)

    Message.Text = BookTreeView.SelectedNode.Text + " node selected.";


  void Node_Expanded(Object sender, TreeNodeEventArgs e)

    Message.Text = e.Node.Text + " node expanded.";


  void Node_Collapsed(Object sender, TreeNodeEventArgs e)

    Message.Text = "";



<html xmlns="" >
  <head runat="server">
    <title>TreeNodeBinding SelectAction Example</title>
    <form id="form1" runat="server">

      <h3>TreeNodeBinding SelectAction Example</h3>

      <asp:TreeView id="BookTreeView"
        Font-Names= "Arial"

          <asp:TreeNodeBinding DataMember="Book" 
          <asp:TreeNodeBinding DataMember="Chapter" 


      <asp:XmlDataSource id="BookXmlDataSource"  

      <br /><br />

      <asp:Label id="Message" runat="server"/>


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 Heading="Section 2">
    <Chapter Heading="Chapter 2">
        <Section Heading="Section 1">
    <Appendix Heading="Appendix A">

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0