TreeNode.Checked Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets a value that indicates whether the node's check box is selected.

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

public bool Checked { get; set; }
/** @property */
public boolean get_Checked ()

/** @property */
public void set_Checked (boolean value)

public function get Checked () : boolean

public function set Checked (value : boolean)

Property Value

true if the node's check box is selected; otherwise, false. The default is false.

When a node displays a check box, the Checked property is commonly used to specify whether the check box is selected. When the check box associated with a node is selected, the node is automatically added to the CheckedNodes collection of the TreeView control. The Checked property can also be used to determine whether the check box is selected.


It is more common to determine which nodes in the TreeView control have their check boxes selected by iterating through the CheckedNodes collection.

The value of this property is stored in view state.

The following code example demonstrates how to use the Checked property to specify whether a node's check box is selected. It initializes the check boxes of nodes with a depth of one to a selected state. For this example to work correctly, you must copy the sample XML data below to a file named Newsgroup.xml.

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

<script runat="server">

  void Data_Bound(Object sender, TreeNodeEventArgs e)

    // Check the depth of a node as it is being bound to data.
    // Initialize the Checked property to true if the depth is 1.
    if(e.Node.Depth == 1)

      e.Node.Checked = true;


      e.Node.Checked = false;




    <form runat="server">
      <h3>TreeNode Checked Example</h3>
      <asp:TreeView id="NewsgroupTreeView" 
          <asp:TreeNodeBinding DataMember="category" TextField="Name"/>
          <asp:TreeNodeBinding DataMember="group" TextField="Name"/>
      <asp:XmlDataSource id="NewsgroupXmlDataSource"  

The following code is sample XML data for the previous example.

<category name="">
    <group name="microsoft.public.dotnet.framework.aspnet"/>
    <group name=""/>
    <group name="microsoft.public.dotnet.framework.aspnet.webservices"/>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0

Community Additions