Sintassi dichiarativa per il controllo server Web TreeView
Aggiornamento: novembre 2007
Visualizza dati gerarchici, ad esempio un sommario, in una struttura.
<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|1|2|3|4|5|6|7|8|9|10|11|12|13|
14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|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"
href="uri"
hrefField="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"
href="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>
Note
Il controllo TreeView consente di visualizzare dati gerarchici, ad esempio un sommario o una directory di file, in una struttura e supporta le seguenti funzionalità:
Supporto per l'associazione dati, che consente di associare i nodi del controllo a dati XML, tabulari o relazionali.
Supporto per gli spostamenti all'interno del sito mediante l'integrazione con il controllo SiteMapDataSource.
Possibilità di visualizzare il testo dei nodi come testo normale o come collegamenti ipertestuali.
Accesso a livello di codice al modello a oggetti TreeView, che consente di creare strutture, inserire dati nei nodi, impostare proprietà ed eseguire altre operazioni in modo dinamico.
Inserimento di dati nei nodi sul lato client (sui browser supportati).
Possibilità di visualizzare una casella di controllo accanto a ciascun nodo.
Possibilità di personalizzare l'aspetto mediante temi, immagini definite dall'utente e stili.
Per ulteriori informazioni sul controllo TreeView, vedere Cenni preliminari sul controllo server Web TreeView.
Esempio
Nell'esempio di codice riportato di seguito viene illustrato come associare il controllo TreeView a un'origine dati XML.
<asp:TreeView id="BookTreeView" dataSourceID="BookXmlDataSource" runat="server">
<DataBindings>
<asp:TreeNodeBinding DataMember="Book" TextField="Title"/>
<asp:TreeNodeBinding DataMember="Chapter" TextField="Heading"/>
<asp:TreeNodeBinding DataMember="Section" TextField="Heading"/>
</DataBindings>
</asp:TreeView>
<asp:XmlDataSource id="BookXmlDataSource" runat="server">
<Data>
<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>
</Book>
</Data>
</asp:XmlDataSource>
<asp:TreeView id="BookTreeView" dataSourceID="BookXmlDataSource" runat="server">
<DataBindings>
<asp:TreeNodeBinding DataMember="Book" TextField="Title"/>
<asp:TreeNodeBinding DataMember="Chapter" TextField="Heading"/>
<asp:TreeNodeBinding DataMember="Section" TextField="Heading"/>
</DataBindings>
</asp:TreeView>
<asp:XmlDataSource id="BookXmlDataSource" runat="server">
<Data>
<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>
</Book>
</Data>
</asp:XmlDataSource>