Shirley

Shirley

  • NA
  • 1
  • 0

Treeview C# and the Nested Set Model

Aug 12 2008 4:38 AM

we're develoing an application that has an ever changing set of categories, and have decided to try using the Nested Set method to mange the categories.

The problem I'm having is getting the results of the list of categories into a Treeview.
The table i get from the database shows the values as :
Title         |Depth
Electronics   |   0
Televisions   |   1
LCD           |   2
Plasma        |   2
CheapPlasma   |   3
ExpensivePLasm|   3
CRT           |   2

The list is in order, so the higher the depth the further down the tree we are. My problem Is  cannot get the damn tree to appear properly as adding nodes to the TreeView are also horizontal as well as vertical (tNode.Nodes[0].Nodes[1].Nodes.Text = CheapPlasma).

With a recursive function i can get it process 2 deep, but when it has to append a value behind the existing one then (for instance CRT is at the same level as PLASMA but behind ExpenisvePlasma), then it goes to the wall.

Can some one point me in the direction for some resources about dealing with hierachial data. Or failing that laugh, and show us a pseudo implimentation

thanks!