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:
[C#]
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();
[Visual Basic]
Public Class Employee
Public Sub New(ByVal name As String,
ByVal position As String)
Me._Name = name
Me._Position = position
End Sub
Public ReadOnly Property Name As String
Get
Return Me._Name
End Get
End Property
Public ReadOnly Property Position As String
Get
Return Me._Position
End Get
End Property
Private _Name As String
Private _Position As String
End Class
menu1.DataSource = new Employee(){
New Employee("John", "Developer"), New Employee("Sam", "Sales Manager")}
menu1.DataBind
[HTML]
<eo:Menu Runat="server" id="menu1">
<TopGroup>
<Bindings>
<eo:DataBinding
Property="Text-Html" DataField="Name">
</eo:DataBinding>
</Bindings>
</TopGroup>
</eo:Menu>
Note:
DataField is used to
specify the source property name when the individual object is not an ADO.Net
object.