c# - How to get data from SQL Server and create a treeview in ASP.NET? -


i have sql server procedure returns categories. category table has foreign key because categories have parent_id column same table.

i send these data sql server in way:

select id, title, desciption, parent_id category xml auto, root('categories'), elements 

and these data in c# program by:

using (xmlreader xml = cmd.executexmlreader()) {    xml.read();    categories = xml.readouterxml(); } 

and pass asp.net class need create treeview these data.

i need make treeview considering parent_id make category , sub-category nodes correctly.

and think recursive algorithm should used.

how should it?

since you've got xml data, recommend trying xmldatasource. since xmldatasource hierarchicaldatasourcecontrol, treeview can use populate itself.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -