Multilevel nested product categories display with asp.net and sql server?

Posted by Kunal on Stack Overflow See other posts from Stack Overflow or by Kunal
Published on 2010-06-09T08:56:05Z Indexed on 2010/06/09 9:02 UTC
Read the original article Hit count: 311

I have a product category table with the following fields:

cat_id (PK)

Cat_name

Cat_desc

Parent_Cat_Id

Now when a user wants to add a product he should be able to select multiple categories from a listbox(multiselection enabaled). But to let the user know the hierarchy of the categories, I need to display them in the following style:

parent category 1

parent category 1->sub category 1

parent category 1->sub category 1->sub-sub category 1

parent category 1->sub category 1->sub-sub category 2

parent category 1->sub category 2

Parent category 2

...

I know that to achieve this I need to use recursive programming. But how can we do it via stored procedures? That would be much more efficient, right?

Thanks in advance for your kind help.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about sql