TreeNodeBinding.Depth Property

Gets or sets the node depth at which the TreeNodeBinding object is applied.

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

[TypeConverterAttribute(L"System.Web.UI.Design.WebControls.TreeNodeBindingDepthConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] 
public:
property int Depth {
	int get ();
	void set (int value);
}
/** @property */
public int get_Depth ()

/** @property */
public void set_Depth (int value)

public function get Depth () : int

public function set Depth (value : int)

Not applicable.

Property Value

The node depth at which the TreeNodeBinding object is applied. The default is -1, indicating that the Depth property is not set.

A node depth specifies the node level that gets bound. For example, the following TreeNodeBinding declaration binds the Name and ID fields of the data source to the Text and Value properties, respectively, of all nodes with a depth of 0:

<asp:TreeNodeBinding Depth="0" TextField="Name" ValueField="ID">

When creating a TreeNodeBinding object, you must specify the criteria for binding. The criteria indicates when a data item should be bound to a node. You can specify the Depth or DataMember property, or both properties. There is a slight performance gain by specifying both.

Once the binding criteria is established, you can then bind a property of a TreeNode object that can be bound to a value. You can bind to a field of a data item or to a static value. When bound to a static value, all TreeNode objects to which the TreeNodeBinding object is applied share the same value.

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 Depth property to apply a TreeNodeBinding object at a specific node depth. The second code example provides sample XML data for the first code example.

The following code example demonstrates how to use the Depth property to apply a TreeNodeBinding object at a specific node depth. For this example to work correctly, you must copy the sample XML data, provided after this code example, to a file named Book.xml.

No code example is currently available or this language may not be supported.

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

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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show: