Table of Contents
- Getting Started
- EO.Pdf
- EO.Web
- Overview
- Installation & Deployement
- EO.Web ToolTip
- EO.Web Rating
- EO.Web Slider & RangeSlider
- EO.Web ListBox
- EO.Web ComboBox
- EO.Web Captcha
- EO.Web ASPX To PDF
- EO.Web Slide
- EO.Web Flyout
- EO.Web EditableLabel
- EO.Web ImageZoom
- EO.Web Floater
- EO.Web Downloader
- EO.Web ColorPicker
- EO.Web HTML Editor
- EO.Web File Explorer
- EO.Web SpellChecker
- EO.Web Grid
- EO.Web MaskedEdit
- EO.Web Splitter
- EO.Web Menu
- EO.Web Slide Menu
- EO.Web TabStrip
- EO.Web TreeView
- EO.Web TreeView
- Overview
- Using EO.Web TreeView
- TreeNode and TreeNodeGroup
- Look, Skin and Theme
- Style and Appearance
- Data Binding
- Handling Event
- EO.Web Calendar
- EO.Web Callback
- EO.Web MultiPage
- EO.Web Dialog
- EO.Web AJAXUploader
- EO.Web ProgressBar - Free!
- EO.Web ToolBar - Free!
- EO.WebBrowser
- EO.Wpf
- Common Topics
- Reference
Populating using Parent/Child key relation |
Apply to
Overview
EO.Web controls can populate hierarchical navigation item structure from a table that contains parent/child key. This is especially convenient when parent and child record have the same data structure and the depth of the control is not known in advance.
How to define hierarchical data structure using Parent/Child key
Considering the following Folders table:
FolderID | ParentFolderID | FolderName |
---|---|---|
1 | null | Root |
2 | 1 | My Documents |
3 | 1 | Windows |
4 | 3 | System32 |
5 | 3 | Temp |
This table represents a hierarchical data structure of:
Root
My Documents
Windows
System32
Temp
The depth of the tree is dynamic.
Populating the control
To populate an EO.Web control from this data source, use a DataSet object and a DataRelation object.
The DataRelation object defines a relation within the same table.
Note: The Nested property of all DataRelation objects must be set to true. If there are additional DataRelation objects in the same DataSet, you should also set DataTable property to the name of the data table.
See live demo and demo source code for details.
Mapping data field to item's property
When binding to a table with parent/child key, by default data field value in
records are assigned to an item's Text.Html
property. For example, for the DataSet shown above, set DataFields
property to "FolderName" means mapping data field "FolderName"
to item's Text.Html property.
If you intend to map data field value to other property, you can define one or
more DataBinding objects to
customize the mapping between a specific data field and a specific property.
The code below maps data field "FolderName" to item's
Value property:
<eo:Menu Runat="server" DataFields="FolderName"> .... <TopGroup> <Bindings> <eo:DataBinding Property="Value" DataField="FolderName"> </eo:DataBinding> </Bindings> </TopGroup> .... </eo:Menu>
Summary
- Drag an EO.Web navigation control onto the page;
- Create a DataTable object, fill the DataTable object. Note that both parent and child key columns are in the same table;
- Create a DataSet object and define parent key and child key DataRelation object in the DataSet and set its Nested property to true;
- Set the control or group's DataSource property to the DataSet object;
- If you also reuse the same DataSet for other code and need to have more DataRelation objects in the same data set, you should also set DataTable property to the name of the data table;
- Optionally, define one or more DataBinding objects on for the control or group;
- Call DataBind method on the control or group.