Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Categories into treeview

Author  Topic 

isvaljek
Starting Member

2 Posts

Posted - 2009-03-26 : 06:01:06
I'm trying to populate asp.net treeview control using table data structured as

idCat
idParentCat
idName

...what I've came up with for now is going through all the categories starting with the ones that have idParentCat == -1 to the last subcategory using query by query, but that doesn't seem very effective.
Is there a faster way to transform my table data into hierarchical format that's needed for treeview control?
I'm using SQL Server 2005 express on my development machine, but I also have a full blown version running on godaddy host.

kunal.mehta
Yak Posting Veteran

83 Posts

Posted - 2009-04-07 : 06:19:31
Hi,
use recursive function which filters the table by parentid and add a node to the tree view control.
Do this until u find out node with no child nodes.
I think this may help.
I can give u the code snippet if u want
Kunal
Go to Top of Page

isvaljek
Starting Member

2 Posts

Posted - 2009-04-07 : 10:20:39
I've read an article on SQLS recursion some time ago, so I'm not really uptodate on the topic and would really appreciate a sample code.

Thanks.
Go to Top of Page
   

- Advertisement -