469,331 Members | 5,445 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,331 developers. It's quick & easy.

I need help populating a treeview correclty

I have a dataset dsMain in which I have two tables

The table period has columns like period_id, name, root_org_id....
The table organization has org_id, name, parent_id, hier_path, level,
org_index, and period_id.

There is a one to many relationship between period and organization, but the
organization is actually a hierarchy.
period.root_or_id represents the org_id of the root node of the
organization hierarchy and that organization should be the first node of the

In my application I have a combobox that I populate with the period data.
So when the form loads cmbPeriod.items[0] represents the first period. Its
ValueMember is the period_id of the first period and I currently use that
data with a parameterized query to fill or refill the organization table as

Once I have done that, however, I am not sure how to use the code to access
a specific record or the organization table to find the record associated
with the root_org_id.
1. I am not exactly sure how to access the root_org_id value of the
currently selected period item of the combobox.
2. I am not sure how to use that value to index into the organization table
to find the right record. I am guessing that you can use index like syntax
with tables and rows, but I have never tried it and I don't have any samples
to go by. I don't know how to set which column to index on.

After I get that done, then I need to develop an algorithm to build the rest
of the tree. I have seen recursive algorithms used with directory trees and
that might work, but I am not sure how I would tell I was at the leaf node.
There are a number of possible fields to use in the organization table, the
parent_id = -1 for the root node and has the value of its immediate parent
for all other nodes. The level field = 0 for the root node and increments
for all subsequent levels. The hier_path field is a string field in the
form "|0|1001|...|1005|" where the vertical bars are delimiters and the
values are text representation of the org_ids of that records and all its

Can someone please point me in the right direction?
Nov 17 '05 #1
0 1112

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.