HighTechTalks DotNet Forums  

loading a treeview in asp.net

ASP.net Web Controls microsoft.public.dotnet.framework.aspnet.webcontrols


Discuss loading a treeview in asp.net in the ASP.net Web Controls forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Erick
 
Posts: n/a

Default loading a treeview in asp.net - 12-13-2007 , 01:28 AM






Can some one help me with loading a treeview in asp.net 2.0

I have a table with records and each record has a column that has a
value which points to the parents record id.
All examples i have seen on the internet load the top node and then
call the database again once a node is clicked.

I would like to load the entire table into a tree view.
I'd rather not have to go through using an xml file.

Does anyone have the code for filling the tree view completely?
Do the records in the referencing table need to be in a specified
sequence ?
Do you need to use treeview1.findnode. Is this a slow method and how
is it used ?

thanks.

Reply With Quote
  #2  
Old   
John Padilla
 
Posts: n/a

Default RE: loading a treeview in asp.net - 12-15-2007 , 01:32 PM






Eric,

i use the tree view as a menu system in my Asp.Net apps.

In my system i have a heiarchy, a bunch of parent Nodes (Categories) with
child nodes and it all comes from a database. The menu child items redirect
uses to the proper pages.

Example:

dsYourData is a DataSet. You cant use foreach with a DataTable so if you are
using DataTable or any iEnumerable type then use for(i=0;
YourEnumerableObject.Count, i++) {}

foreach (DataRow curParentRow in dsYourData.Tables[0].Rows)
{
SetNewParentNodeNode((string)curRow["ParentName"],
(string)curRow["parentId"]);
}

private void SetNewParentNodeNode(string ParentName, string ParentId)
{
TreeNode ParentNode = new TreeNode();
ParentNode .Text = ParentName;
ParentNode .Value = "ParentId";

tvYourTreeView.Nodes.Add(ParentNode );
}

Hope this helps!

"Erick" wrote:

Quote:
Can some one help me with loading a treeview in asp.net 2.0

I have a table with records and each record has a column that has a
value which points to the parents record id.
All examples i have seen on the internet load the top node and then
call the database again once a node is clicked.

I would like to load the entire table into a tree view.
I'd rather not have to go through using an xml file.

Does anyone have the code for filling the tree view completely?
Do the records in the referencing table need to be in a specified
sequence ?
Do you need to use treeview1.findnode. Is this a slow method and how
is it used ?

thanks.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.