Skip to content

DevExpress-Examples/asp-net-web-forms-treeview-bind-to-plain-data-unbound-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tree View for ASP.NET Web Forms - How to bind the tree to plain data (Unbound mode)

This example demonstrates how to bind ASPxTreeView to data stored in DataTable. Nodes are created in unbound mode.

protected void Page_Load(object sender, EventArgs e) {
    DataTable table = GetDataTable();
    if (!IsPostBack)
        CreateTreeViewNodesRecursive(table, this.treeView.Nodes, "0");
}

private void CreateTreeViewNodesRecursive(DataTable table, TreeViewNodeCollection nodesCollection, string parentID) {
    for (int i = 0; i < table.Rows.Count; i++) {
        if (table.Rows[i]["ParentID"].ToString() == parentID) {
            TreeViewNode node = new TreeViewNode(table.Rows[i]["Title"].ToString(), table.Rows[i]["ID"].ToString());
            nodesCollection.Add(node);
            CreateTreeViewNodesRecursive(table, node.Nodes, node.Name);
        }
    }
}

Files to Review

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Bind ASPxTreeView to data stored in DataTable.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •