Okay.
Here is the code in ASPX:
BorderColor="Silver" BorderWidth="1px" Height="320px" Width="280px" Padding="1px"
FadeEffect="True" WideCell="True" ExpandLevel="1" ContentClickCollapses="true" OnNodeDataBound="flyTreeView_NodeDataBound">
RowHeight="18px" />
And the code-behind:
using System;
using System.Data;
using System.Web;
using System.Web.UI;
using NineRays.WebControls;
public partial class Demo_DataBinding_Tabular : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Create sample data
DataTable dTable = new DataTable("Orders");
dTable.Columns.Add("ID");
dTable.Columns.Add("Title");
dTable.Columns.Add("URL");
// Add nodes (OwnerID is null for root nodes)
dTable.Rows.Add(new object[] { 1, "Developer Tools", "http://www.9rays.net/" });
dTable.Rows.Add(new object[] { 2, "Spices.Net" });
dTable.Rows.Add(new object[] { 3, "Spices.Obfuscator" });
dTable.Rows.Add(new object[] { 4, "Spices.Decompiler" });
dTable.Rows.Add(new object[] { 5, ".Net Controls" });
dTable.Rows.Add(new object[] { 6, "FlyGrid.Net" });
dTable.Rows.Add(new object[] { 7, "FlyTreeView for ASP.NET 1.1" });
dTable.Rows.Add(new object[] { 8, "FlyTreeView for ASP.NET 2.0" });
// Bind the treeview
flyTreeView.DataSource = CreateHierarchichal(dTable);
flyTreeView.DataBind();
}
}
private IHierarchicalEnumerable CreateHierarchichal(DataTable datatale)
{
// this is the way we can create IHierarchicalEnumerable from every table
return FlyTreeView.ConvertTabularDataToHierarchical(datatale, "ID", "ID");
}
protected void flyTreeView_NodeDataBound(object sender, FlyTreeNodeEventArgs e)
{
if (e.Node.Level > 1) return;
// THERE SHOULD SOME CALL TO DATA SOURCE TO GET VALID DATA FOR CHILD NODES
DataTable dTable = new DataTable("Orders");
dTable.Columns.Add("ID");
dTable.Columns.Add("Title");
dTable.Columns.Add("NewURLField");
// Add nodes (OwnerID is null for root nodes)
dTable.Rows.Add(new object[] { 1, "Developer Tools", "http://www.9rays.net/"});
dTable.Rows.Add(new object[] { 2, "Spices.Net" });
// for every created node
e.Node.ChildNodes.DataSource = CreateHierarchichal(dTable);
e.Node.ChildNodes.DataBind();
}
}
Of course, there're some unneeded stuff in its setting (I took the standard demo to create it), but the general approach seems to be visible.