System.Web.UI.WebControls.Menu.DataBindings Property

Gets a collection of System.Web.UI.WebControls.MenuItemBinding objects that define the relationship between a data item and the menu item it is binding to.

Syntax

[System.ComponentModel.MergableProperty(false)]
[System.ComponentModel.Editor("System.Web.UI.Design.WebControls.MenuBindingsEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
[System.ComponentModel.DefaultValue(null)]
public MenuItemBindingCollection DataBindings { get; }

Value

Documentation for this section has not yet been entered.

Remarks

The Menu.DataBindings collection contains System.Web.UI.WebControls.MenuItemBinding objects that define the relationship between a data item and the menu item it is binding to. When binding to a data source where each data item contains multiple properties (such as an XML element with several attributes), a menu item displays the value returned by the ToString() method of the data item by default. In the case of an XML element, the menu item displays the element name, which shows the underlying structure of the tree, but is not very useful otherwise. You can bind a menu item to a specific data item property by specifying menu item bindings.

When defining the relationship between a data item and a menu item, you must specify both the criteria for binding and the property of a data item to bind to. The criteria indicate when a data item should be bound to a menu item. The criteria can be specified with a depth, a data member, or both. The depth specifies the menu level that gets bound. For example, if you specify a depth of 0, all menu items in the tree structure at level 0 are bound using the menu item binding. A data member specifies the type of the data item in the underlying data source, but can represent different information depending on the data source. For example, the data member for an XML element specifies the name of the element.

If multiple System.Web.UI.WebControls.MenuItemBinding objects are defined that conflict with each other, the System.Web.UI.WebControls.Menu control applies the menu item bindings in the following order of precedence:

[The 'ordered' type of list has not been implemented in the ECMA stylesheet.]

Once the binding criteria are established, you can then bind a property of a System.Web.UI.WebControls.MenuItem object that is able to be bound to an attribute or field of a data item. For example, you can bind the MenuItem.Text property of a menu item to the text attribute on an XML element by setting the MenuItemBinding.TextField property of a System.Web.UI.WebControls.MenuItemBinding object. You can also bind to a static value. If you set the MenuItemBinding.Text property of a System.Web.UI.WebControls.MenuItemBinding object, all menu items to which the System.Web.UI.WebControls.MenuItemBinding object is applied share the same static text value. For more information on binding the properties of a System.Web.UI.WebControls.MenuItem object to a value, see System.Web.UI.WebControls.MenuItemBinding.

Although the Menu.DataBindings collection can be programmatically populated, it is usually set declaratively. To specify the menu item bindings, first nest opening and closing <DataBindings> tags between the opening and closing tags of the System.Web.UI.WebControls.Menu control. Next, place <asp:MenuItemBinding> elements between the opening and closing <DataBindings> tags for each menu item binding you want to specify.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0