System.Web.UI.WebControls Namespace MenuItem Class
.NET Framework version 2.0
Returns a collection of MenuItem objects that represents the first-level child menu items of the current node in a Menu control.
Script |
[ MenuItemCollection variable = ] MenuItem.ChildItems |
variable |
Returns a MenuItemCollection that contains the first-level child menu items of the current node in a Menu. |
The property is read only with no default value.
Use the ChildItems collection to programmatically obtain information about each of the first-level child menu items of the current node in a Menu control. This collection is typically used to iterate through all the child menu items, or to access a specific child menu item, of the current node.
The ChildItems property can also be used to programmatically add, insert, or remove MenuItem objects in the collection. Any updates to the collection are automatically reflected in the MenuItem control after the next round trip to the server.
To access the child menu items further down the tree, use the ChildItems property of the next-level child menu item to navigate down the menu hierarchy.
The following example shows how to programmatically add child menu item objects to the ChildItems collection of a root or parent MenuItem control.
MenuItem newItem = new MenuItem ( menuItemText, menuItemValue );
newItem.NavigateUrl = webPageUrl;
parentMenuObject.ChildItems.Add ( newItem );
Dim newItem As New MenuItem ( menuItemText, menuItemValue )
newItem.NavigateUrl = webPageUrl
parentMenuObject.ChildItems.Add ( newItem ) |
|
C# |
VB |
Show me
MenuItem Members