ASP.NET Syntax ASP.NET Syntax for Web Controls
Displays hierarchical data, such as a table of contents, in a tree structure.
Declarative Syntax
<asp:TreeView
AccessKey = "string"
AutoGenerateDataBindings = "True | False"
BackColor = "color name | #dddddd"
BorderColor = "color name | #dddddd"
BorderStyle = "NotSet | None | Dotted | Dashed | Solid | Double | Groove |
Ridge | Inset | Outset"
BorderWidth = size
CollapseImageToolTip = "string"
CollapseImageUrl = "uri"
CssClass = "string"
DataSource = "string"
DataSourceID = "string"
EnableClientScript = "True | False"
Enabled = "True | False"
EnableTheming = "True | False"
EnableViewState = "True | False"
ExpandDepth = "string | FullyExpand | 0 - 30"
ExpandImageToolTip = "string"
ExpandImageUrl = "uri"
Font-Bold = "True | False"
Font-Italic = "True | False"
Font-Names = "string"
Font-Overline = "True | False"
Font-Size = "string | Smaller | Larger | XX-Small | X-Small | Small |
Medium | Large | X-Large | XX-Large"
Font-Strikeout = "True | False"
Font-Underline = "True | False"
ForeColor = "color name | #dddddd"
Height = size
ID = "string"
ImageSet = "Custom | XPFileExplorer | Msdn | WindowsHelp | Simple |
Simple2 | BulletedList | BulletedList2 | BulletedList3 |
BulletedList4 | Arrows | News | Contacts | Inbox | Events | Faq"
LineImagesFolder = "string"
MaxDataBindDepth = integer
NodeIndent = integer
NodeWrap = "True | False"
NoExpandImageUrl = "uri"
OnDataBinding = "DataBinding event handler"
OnDataBound = "DataBound event handler"
OnDisposed = "Disposed event handler"
OnInit = "Init event handler"
OnLoad = "Load event handler"
OnPreRender = "PreRender event handler"
OnSelectedNodeChanged = "SelectedNodeChanged event handler"
OnTreeNodeCheckChanged = "TreeNodeCheckChanged event handler"
OnTreeNodeCollapsed = "TreeNodeCollapsed event handler"
OnTreeNodeDataBound = "TreeNodeDataBound event handler"
OnTreeNodeExpanded = "TreeNodeExpanded event handler"
OnTreeNodePopulate = "TreeNodePopulate event handler"
OnUnload = "Unload event handler"
PathSeparator = "string"
PopulateNodesFromClient = "True | False"
runat = "server"
ShowCheckBoxes = "None | Root | Parent | Leaf | All"
ShowExpandCollapse = "True | False"
ShowLines = "True | False"
SkinID = "string"
SkipLinkText = "string"
Style = "string"
TabIndex = integer
Target = "string"
ToolTip = "string"
Visible = "True | False"
Width = size
>
<DataBindings>
<asp:TreeNodeBinding
DataMember = "string"
Depth = integer
FormatString = "string"
ImageToolTip = "string"
ImageToolTipField = "string"
ImageUrl = "uri"
ImageUrlField = "string"
NavigateUrl = "uri"
NavigateUrlField = "string"
PopulateOnDemand = "True | False"
SelectAction = "Select | Expand | SelectExpand | None"
ShowCheckBox = "string"
Target = "string"
TargetField = "string"
Text = "string"
TextField = "string"
ToolTip = "string"
ToolTipField = "string"
Value = "string"
ValueField = "string"
/>
</DataBindings>
<HoverNodeStyle />
<LeafNodeStyle
BackColor = "color name | #dddddd"
BorderColor = "color name | #dddddd"
BorderStyle = "NotSet | None | Dotted | Dashed | Solid | Double |
Groove | Ridge | Inset | Outset"
BorderWidth = size
ChildNodesPadding = size
CssClass = "string"
Font-Bold = "True | False"
Font-Italic = "True | False"
Font-Names = "string"
Font-Overline = "True | False"
Font-Size = "string | Smaller | Larger | XX-Small | X-Small | Small |
Medium | Large | X-Large | XX-Large"
Font-Strikeout = "True | False"
Font-Underline = "True | False"
ForeColor = "color name | #dddddd"
Height = size
HorizontalPadding = size
ImageUrl = "uri"
NodeSpacing = size
OnDisposed = "Disposed event handler"
VerticalPadding = size
Width = size
/>
<LevelStyles>
<asp:TreeNodeStyle
BackColor = "color name | #dddddd"
BorderColor = "color name | #dddddd"
BorderStyle = "NotSet | None | Dotted | Dashed | Solid |
Double | Groove | Ridge | Inset | Outset"
BorderWidth = size
ChildNodesPadding = size
CssClass = "string"
Font-Bold = "True | False"
Font-Italic = "True | False"
Font-Names = "string"
Font-Overline = "True | False"
Font-Size = "string | Smaller | Larger | XX-Small |
X-Small | Small | Medium | Large | X-Large | XX-Large"
Font-Strikeout = "True | False"
Font-Underline = "True | False"
ForeColor = "color name | #dddddd"
Height = size
HorizontalPadding = size
ImageUrl = "uri"
NodeSpacing = size
OnDisposed = "Disposed event handler"
VerticalPadding = size
Width = size
/>
</LevelStyles>
<Nodes>
<asp:TreeNode
Checked = "True | False"
Expanded = "string"
ImageToolTip = "string"
ImageUrl = "uri"
NavigateUrl = "uri"
PopulateOnDemand = "True | False"
SelectAction = "Select | Expand | SelectExpand | None"
Selected = "True | False"
ShowCheckBox = "string"
Target = "string"
Text = "string"
ToolTip = "string"
Value = "string"
>
</asp:TreeNode>
</Nodes>
<NodeStyle
BackColor = "color name | #dddddd"
BorderColor = "color name | #dddddd"
BorderStyle = "NotSet | None | Dotted | Dashed | Solid | Double |
Groove | Ridge | Inset | Outset"
BorderWidth = size
ChildNodesPadding = size
CssClass = "string"
Font-Bold = "True | False"
Font-Italic = "True | False"
Font-Names = "string"
Font-Overline = "True | False"
Font-Size = "string | Smaller | Larger | XX-Small | X-Small | Small |
Medium | Large | X-Large | XX-Large"
Font-Strikeout = "True | False"
Font-Underline = "True | False"
ForeColor = "color name | #dddddd"
Height = size
HorizontalPadding = size
ImageUrl = "uri"
NodeSpacing = size
OnDisposed = "Disposed event handler"
VerticalPadding = size
Width = size
/>
<ParentNodeStyle
BackColor = "color name | #dddddd"
BorderColor = "color name | #dddddd"
BorderStyle = "NotSet | None | Dotted | Dashed | Solid | Double |
Groove | Ridge | Inset | Outset"
BorderWidth = size
ChildNodesPadding = size
CssClass = "string"
Font-Bold = "True | False"
Font-Italic = "True | False"
Font-Names = "string"
Font-Overline = "True | False"
Font-Size = "string | Smaller | Larger | XX-Small | X-Small | Small |
Medium | Large | X-Large | XX-Large"
Font-Strikeout = "True | False"
Font-Underline = "True | False"
ForeColor = "color name | #dddddd"
Height = size
HorizontalPadding = size
ImageUrl = "uri"
NodeSpacing = size
OnDisposed = "Disposed event handler"
VerticalPadding = size
Width = size
/>
<RootNodeStyle
BackColor = "color name | #dddddd"
BorderColor = "color name | #dddddd"
BorderStyle = "NotSet | None | Dotted | Dashed | Solid | Double |
Groove | Ridge | Inset | Outset"
BorderWidth = size
ChildNodesPadding = size
CssClass = "string"
Font-Bold = "True | False"
Font-Italic = "True | False"
Font-Names = "string"
Font-Overline = "True | False"
Font-Size = "string | Smaller | Larger | XX-Small | X-Small | Small |
Medium | Large | X-Large | XX-Large"
Font-Strikeout = "True | False"
Font-Underline = "True | False"
ForeColor = "color name | #dddddd"
Height = size
HorizontalPadding = size
ImageUrl = "uri"
NodeSpacing = size
OnDisposed = "Disposed event handler"
VerticalPadding = size
Width = size
/>
<SelectedNodeStyle
BackColor = "color name | #dddddd"
BorderColor = "color name | #dddddd"
BorderStyle = "NotSet | None | Dotted | Dashed | Solid | Double |
Groove | Ridge | Inset | Outset"
BorderWidth = size
ChildNodesPadding = size
CssClass = "string"
Font-Bold = "True | False"
Font-Italic = "True | False"
Font-Names = "string"
Font-Overline = "True | False"
Font-Size = "string | Smaller | Larger | XX-Small | X-Small | Small |
Medium | Large | X-Large | XX-Large"
Font-Strikeout = "True | False"
Font-Underline = "True | False"
ForeColor = "color name | #dddddd"
Height = size
HorizontalPadding = size
ImageUrl = "uri"
NodeSpacing = size
OnDisposed = "Disposed event handler"
VerticalPadding = size
Width = size
/>
</asp:TreeView>
For information on the individual members of this class, see TreeView in the class library.
The TreeView control renders hierarchical data, such as a table of contents or file directory, into a tree-like structure, and supports the following features:
- Data binding support that allows the nodes of the control to be bound to XML, tabular, or relational data.
- Site navigation support through integration with the SiteMapDataSource control.
- Node text that can be displayed as either plain text or hyperlinks.
- Programmatic access to the TreeView object model to create trees, populate nodes, set properties, and so on, dynamically.
- Client-side node population (on supported browsers).
- The ability to display a check box next to each node.
- The ability to customize appearance through themes, user-defined images, and styles.
The following example demonstrates how to bind the TreeView control to a SiteMapDataSource control.
<asp:treeview id="myTreeView" runat="server"
datasourceid="siteMap"
expanddepth=1 />
<asp:sitemapdatasource id="siteMap" runat="server" />
Show me
TreeView Class TreeView Web Server Control