By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,112 Members | 1,601 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,112 IT Pros & Developers. It's quick & easy.

managing hierarchical data - categories

P: n/a
Hi,

I want to store product categories in my db and am a little lost as to where
to start.

They can be hierarchical, such as "Books" > "Cook Books", so my table is
like this:

int CategoryId
int ParentCategoryId Nullable
string Description

with a foreign key from ParentCategoryId to CategoryId

I want to have the following functionality on my site:

list top level categories (those with no ParentCategoryId)
list subcategories of a category (1 level deep)
list full "path" of a category ("Books" > "Home Decorating" > "Criminals" >
"Martha Stuart")

put all the categories in a treeview control (don't know which one)
put all the categories in a select menu, like this:

<select>
<optGroup label="Books">
<option value="1">All</option>
<option value="3">Cooking</option>
<option value="99">Computers</option>
<optgroup label="Phones">
<option value=22>All></option>
<option value=44>Motorola</option>
</optgroup>
</optgroup>
<optgroup label="Cars">
<option value=5>All</option>
<option value=33>Mazdas</option>
</optgroup>
</select>

What is the best way to do this? I don't need help on how to display the
info once I have it, but I'd like to know how to efficiently retrieve it
from the database and store it in the appropriate data structure (pref C#).
I noticed the WebForms tree control has some of the functionality I want
such as the FullPath property, but there doesn't seem to be a similar one
for web forms. Thanks!

Neil M
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
What do you thinj about this tree...

http://www.eztree-msdn.com

Thanks

lj

"Neil McGuigan" <no*****************@shaw.ca> a écrit dans le message de
news: gEh2c.693730$JQ1.615001@pd7tw1no...
Hi,

I want to store product categories in my db and am a little lost as to where to start.

They can be hierarchical, such as "Books" > "Cook Books", so my table is
like this:

int CategoryId
int ParentCategoryId Nullable
string Description

with a foreign key from ParentCategoryId to CategoryId

I want to have the following functionality on my site:

list top level categories (those with no ParentCategoryId)
list subcategories of a category (1 level deep)
list full "path" of a category ("Books" > "Home Decorating" > "Criminals"

"Martha Stuart")

put all the categories in a treeview control (don't know which one)
put all the categories in a select menu, like this:

<select>
<optGroup label="Books">
<option value="1">All</option>
<option value="3">Cooking</option>
<option value="99">Computers</option>
<optgroup label="Phones">
<option value=22>All></option>
<option value=44>Motorola</option>
</optgroup>
</optgroup>
<optgroup label="Cars">
<option value=5>All</option>
<option value=33>Mazdas</option>
</optgroup>
</select>

What is the best way to do this? I don't need help on how to display the
info once I have it, but I'd like to know how to efficiently retrieve it
from the database and store it in the appropriate data structure (pref C#). I noticed the WebForms tree control has some of the functionality I want
such as the FullPath property, but there doesn't seem to be a similar one
for web forms. Thanks!

Neil M

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.