N
Neil McGuigan
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
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