Table of Contents
Populating from IEnumerable

Apply to

Menu, SlideMenu, TabStrip and TreeView

Overview

EO.Web navigation controls can populate from any objects that implements IEnumerable interface, such as Array and ArrayList. Since these objects do not represent a hierarchical data structure, binding to such data source does not populate multiple levels of navigation items. For example, if you bind an array to a Menu control, it will only populate the top level group.

Mapping data source object property to item's property

When binding to an object that implements IEnumerable, EO.Web navigation controls iterate through the enumerator, call ToString method on each object in the collection and use the result as navigation item's Text.Html property. You can override this default behavior by defining one or more DataBinding objects, which defines the mapping between the property of objects in IEnumberable collection and item's property. The following example uses Employee.Name as navigation item text:

public class Employee 
{
    private string _Name; 
    private string _Position;
    public Employee(string name, string position) {
    
        _Name= name; 
        _Position = position; 
    } 
    
    public string Name
    {    
        get { return_Name;} 
    } 
    
    public string Position
    {
        get { return _Position; }
    } 
} 
    
menu1.DataSource = new Employee[]{ 
            new Employee("John", "Developer"),
            new Employee("Sam", "Sales Manager")};
menu1.DataBind();

Note:

DataField is used to specify the source property name when the individual object is not an ADO.Net object.