System.Web.UI.WebControls.MenuItemBinding.DataMember Property

Gets or sets the data member to bind to a menu item.

Syntax

[System.ComponentModel.DefaultValue("")]
public string DataMember { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

When creating a System.Web.UI.WebControls.MenuItemBinding object, you must specify the criteria for binding. The criteria indicate when a data item should be bound to a menu item. You can specify the MenuItemBinding.Depth property, the MenuItemBinding.DataMember property, or both.

When the data source contains multiple elements or tables, use the MenuItemBinding.DataMember property to specify the element or table to bind to a menu item. 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. Each data item in a hierarchical data source (represented by a System.Web.UI.IHierarchyData object) exposes a System.Web.UI.IHierarchyData.Type property, which specifies the type of the data item. For example, the data member for an XML element specifies the name of the element. The following System.Web.UI.WebControls.MenuItemBinding declaration binds the <Book> elements of an System.Web.UI.WebControls.XmlDataSource control to all the menu items in the menu, regardless of the location in the hierarchy:

Example

<asp:MenuItemBinding DataMember="Book" TextField="Title" ValueField= "ISBN">

Sometimes you might need to create a menu item binding that specifies both a depth and a data member. This is often used when the data source contains items at different levels that have the same data member value. For example, you can have <Item> elements that appear at different levels within an XML file. The following System.Web.UI.WebControls.MenuItemBinding declarations show how to specify menu item bindings that apply to identical data members at different menu depths:

<asp:MenuItemBinding DataMember="Item" Depth="1" TextField="Title">

<asp:MenuItemBinding DataMember="Item" Depth="2" TextField="ISBN">

If a menu item binding is defined without a depth or a data member, the menu item binding is applied to all menu items within the menu. This is commonly used when all data items have the same properties and should be displayed identically, regardless of the menu depth.

After the binding criteria are established, you can then bind a property of a System.Web.UI.WebControls.MenuItem 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 System.Web.UI.WebControls.MenuItem objects to which the System.Web.UI.WebControls.MenuItemBinding object is applied share the same value. Properties bound to fields contain the values of the field from the data source.

If conflicting System.Web.UI.WebControls.MenuItemBinding objects are defined, 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.]

Requirements

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