Title:
hyperlink to the nodes
Name:
Ryan
Date:
11/5/2009 9:19:20 AM
Comment:
Hi Anitha, Soz for the long wait. What Error is it giving you?
|
Title:
What's the problem with the code download?
Name:
Teemu
Date:
10/26/2009 2:44:16 AM
Comment:
See top of the page "Download Sample Code"
|
Title:
C# code for this program
Name:
Somnath
Date:
10/26/2009 2:27:18 AM
Comment:
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient;
public partial class tree : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { PopulateRootLevel(); } }
private void PopulateRootLevel() { SqlConnection objConn = new SqlConnection("Data Source=localhost;Trusted_Connection=true;DATABASE=swabhiman;user id=sa;password=sa;"); SqlCommand objCommand = new SqlCommand("select id,name,(select count(*) FROM commissioned_detail WHERE introducer_id=sc.id) child FROM commissioned_detail sc where introducer_id ='01900100' order by name", objConn); SqlDataAdapter da = new SqlDataAdapter(objCommand); DataTable dt = new DataTable(); da.Fill(dt); PopulateNodes(dt, TreeView1.Nodes); }
private void PopulateNodes(DataTable dt, TreeNodeCollection nodes) { foreach (DataRow dr in dt.Rows) { TreeNode tn = new TreeNode(); string name = dr["name"].ToString(); string id = dr["id"].ToString(); string com = name + '(' + id+')'; //tn.Text = dr["name"].ToString(); tn.Text = com; tn.Value = dr["id"].ToString(); nodes.Add(tn); //If node has child nodes, then enable on-demand populating tn.PopulateOnDemand = ((int)dr["child"] > 0); } }
private void PopulateSubLevel(int parentid, TreeNode parentNode) { SqlConnection objConn = new SqlConnection("Data Source=localhost;Trusted_Connection=true;DATABASE=swabhiman;user id=sa;password=sa;"); SqlComman
|
Title:
Good article but i need code in C#
Name:
Somnath
Date:
10/26/2009 1:02:40 AM
Comment:
I liked the post.it is really good one .but it will be better if you can give the codes in C#.
By the way Thanks
|
Title:
Incredible Article !!
Name:
malika
Date:
10/22/2009 8:40:22 AM
Comment:
It saved me a lot of time thanks you very much
|
Title:
hyperlink to the nodes
Name:
Anitha
Date:
10/15/2009 4:02:56 PM
Comment:
Hi Ryan, Thanks a lot for the idea and suggestion. I am new to ASP.net ... I tried your code but it gives me errors .... can you Please show me how I can pass the value to the query and again retreieve the value for opening the file from a folder ??? .. All your help will be very much appreciated .... Once again Thank you so very much Ryan ...
Anitha
|
Title:
add a node at any leval
Name:
Ryan
Date:
10/12/2009 4:51:47 AM
Comment:
Hey sam,
could you please explain what you want to do?
|
Title:
Awesome TreeView Control
Name:
Nithya
Date:
10/11/2009 10:23:12 AM
Comment:
Thanks for the code. It saved my time. Happy Coding :)
|
Title:
Its amazing
Name:
Yakub Pasha
Date:
10/10/2009 2:09:15 PM
Comment:
It’s really very good, Thanks a lot for the code .. this is exactly what I wanted.
|
Title:
Low Performance
Name:
Ravikant
Date:
10/6/2009 10:44:27 AM
Comment:
I tried your code. But it takes lot time to show the TreeView.
|
Title:
add a node at any leval
Name:
sam
Date:
10/5/2009 4:58:29 AM
Comment:
Hi can you give me any example of how to add a node at any leval please?
|
Title:
hyperlink to the nodes
Name:
Ryan
Date:
9/21/2009 7:35:50 AM
Comment:
Hi anitha. what you could have is a link or path to a selcted item in the database. You can then add TreeView1.SelectedNode.Value. Then you should use the value that is returned to lookup the column in the database where the path to the specific file is. You can use the following code to get the data.
string databaseconnection = ConfigurationManager.ConnectionStrings["DatabaseName"].ConnectionString; System.Data.SqlClient.SqlConnection myConnection = new System.Data.SqlClient.SqlConnection(databaseconnection); System.Data.SqlClient.SqlCommand myCommand = new System.Data.SqlClient.SqlCommand("SELECT ColumnName FROM Table WHERE ID='" + valueFromTree +"'", myConnection); myConnection.Open(); myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); while (myReader.Read()) { Session["Item"] = Convert.ToString(myReader.GetString(0)); } myReader.Close(); myConnection.Close();
|
Title:
hyperlink to the nodes
Name:
anitha
Date:
9/19/2009 9:26:46 AM
Comment:
Hi .. Thanks a lot for the code .. this is exactly what I wanted but in addition to this .. I would like the nodes to open a attachment when someone clicks on the name for Eg : when they click on Category 2.2.2 it should open a file from a folder .. the name of the file will be from database that is assigned to Category 2.2.2 ...... Can anyone Please help me ..... Please
|
Title:
Need Help!
Name:
Gaurav
Date:
9/16/2009 11:33:16 AM
Comment:
Dear Sir, I have one requirement. When user clicks on Clear button; i want to clear or change the selected node color to default using javascript so that he can asssume that the node is not selected. Please help me to get this.
|
Title:
Excellent Code!!!!!!
Name:
Gaurav
Date:
9/16/2009 11:30:57 AM
Comment:
This code is awesome and unique in its kind. Still very much practical.
|
Title:
Have a hyperlink to a folder
Name:
Anitha
Date:
9/15/2009 11:05:52 AM
Comment:
is it possible to add another tables rows underneath each node ? like for eg: under Category 2.2.2 can I have a Repeater control to a column that opens a file ... Please help me .. Please
|
Title:
Have a hyperlink to a folder
Name:
Anitha
Date:
9/15/2009 11:03:17 AM
Comment:
Hi .. Thanks a lot for the code .. this is exactly what I wanted but in addition to this .. I would like the nodes to open a attachment when someone clicks on the name for Eg : when they click on Category 2.2.2 it should open a file from a folder .. the name of the file will be from database that is assigned to Category 2.2.2 ...... Can anyone Please help me ..... Please
|
Title:
Display a popup window on a treeview node selection
Name:
tambi121
Date:
8/26/2009 7:02:38 AM
Comment:
Could you pl help in resolving the issue propping up when trying to display a pop up window upon selecting a node. I have registered onselectednodeChanged client script event nd was calling javascript function to open a modaldialog window.It was working fine with the link button.Bt with Treeview nothing is opening except printing the method name on the browser.
Could you pl help me in figuring out this issue?
Thanks in advance
|
Title:
help
Name:
noami
Date:
8/17/2009 11:35:51 PM
Comment:
Hi author: I have a table called Category which only have 2 columns and don't have subcategories. How do i modify the codes above in order to make the tree view appeared as below:
Categories: → Ring → Anklet → Bangle → Brooch → Bracelet
My Category table is as below:
CategoryID CategoryName 1 Ring 2 Anklet 3 Bangle 4 Brooch 5 Bracelet
|
Title:
Thanks for the compliments
Name:
Teemu
Date:
7/23/2009 6:38:17 AM
Comment:
Nice to know I've written something useful. :-)
ontreenodepopulate="TreeView1_TreeNodePopulate" is not needed in VB version since sample code has Handles clause there (it is equivalent), though it is matter of taste how one does wire up events.
C# version of the code download has this already.
|
Title:
Great Stuff
Name:
Ryan
Date:
7/23/2009 6:08:05 AM
Comment:
Thanks. This is a great post. Should make a book out of it.
To make the nodes display. Add ontreenodepopulate="TreeView1_TreeNodePopulate" to the treeview that is created in the aspx file. This should solve a big problem
|
Title:
THANKS
Name:
bassam
Date:
7/21/2009 4:19:30 AM
Comment:
I see the link to the sample code when i restor database ti not restor if you can help to get the other backup for database to help me sent by email:bass_57@hotmail.com plssssssssssssssssss ineed this code for multi node
|
Title:
THANKS
Name:
Mark
Date:
7/10/2009 1:51:30 PM
Comment:
I see the link to the sample code has been fixed; thanks. ...and THANKS VERY MUCH for providing a VB version!
Proof of a great sample - look at how long ago you wrote this, and yet still so many people are finding it useful! Thanks again!
|
Title:
Daud
Name:
Daud
Date:
7/9/2009 7:14:30 AM
Comment:
Great work
|
Title:
Thank you
Name:
JYO
Date:
6/24/2009 8:28:50 AM
Comment:
very vERY Thanks
|
Title:
Thank You
Name:
Vikas Vatnani
Date:
6/23/2009 2:49:20 AM
Comment:
I have the code you can mail me on vikasvatnani@gmail.com and i will fwd you the code file
Thanks
|
Title:
"Download Sample Code" link broken?
Name:
Mark
Date:
6/22/2009 12:38:18 AM
Comment:
Hello - is this working for anybody?
|
Title:
Solution to problem where ppl are unable to get the complete tree
Name:
Akanksha Negi
Date:
6/16/2009 5:02:40 PM
Comment:
Hi, Though the reply is too late but may be it can of some help to ppl visiting this article now.
It's in reference to the problem like-
Title: I can't see neither child nodes nor plus icon Name: Taleshi Date: 4/3/2009 1:08:44 PM
/* CODE---*/
cmd.CommandText = "select categoryid,categoryname," + "(select count(*) from category where parentid = category.categoryid) childnodecount " + "from category where parentid IS NULL";
/* remaining CODE--*/
if you re-write it like-
cmd.CommandText = "select categoryid,categoryname," + "(select count(*) from category where parentid = CATEG.categoryid) childnodecount " + "from category as CATEG where parentid IS NULL";
it will work perfectly.
|
Title:
Great Article
Name:
meikjohnson
Date:
6/11/2009 4:47:09 PM
Comment:
First time going through your article, building sql database table and implementing the code in C# worked great. Now I have to enable and disable imageurl's based upon access authentication. thanks again.
|
Title:
Data
Name:
Syed
Date:
6/11/2009 5:04:20 AM
Comment:
Can U send me the Data?. Still I Can't Understand the Data Structure
|
Title:
Good and Best Concept!! Thankyou Sir
Name:
Ashish Sharma (Web Developer)
Date:
6/10/2009 1:12:37 AM
Comment:
thanks for providing the basic and best concept on treeview control. Thanks a lot sir.
|
Title:
That's Ok
Name:
Patibandla
Date:
6/2/2009 9:10:40 AM
Comment:
Hi Teemu,
That's ok but if there are more Controls to be loaded then this will render the page slowly. So how to avoid that
|
Title:
Great Stuff
Name:
V.R.Hari
Date:
5/28/2009 1:48:33 AM
Comment:
Excellent stuff. really cool. works fine for me. thanks...
|
Title:
Use Controls ASCX
Name:
Cas
Date:
5/24/2009 9:58:19 AM
Comment:
This is excellent code and it works well.
However I have been trying to make a WebUserControl of this - I usually load ASCX controls dynamically into an UpdatePanel on demand from a control outside of the UpdatePanel eg: using a choice from a listbox to populate an UpdatePanel (by first clearing it of the existing control and then adding the new control).
However I have been unsuccessful in trying to convert the treeview code in this article to an ASCX file that can be dynamically loaded on demand as descibed above - any ideas/examples ?
|
Title:
Excellent
Name:
New tree view user
Date:
5/19/2009 5:36:22 AM
Comment:
Excellent
|
Title:
Exception with treeview binding
Name:
Prabhu
Date:
5/7/2009 5:16:23 AM
Comment:
As i seened ur article its very usefull to me but at run time it is giving thet System.OverflowException:Arithmetic Overflow exception in counting pls give me the solution as early as possible
|
Title:
Menu
Name:
Maran
Date:
5/4/2009 6:36:21 AM
Comment:
can it be applied for navigation menu whose menu items are soming from database?
|
Title:
TreeView +CheckBoxs
Name:
mgdutt@gmail.com
Date:
4/22/2009 8:28:34 AM
Comment:
Hi
I am populated the data(3 levels) in treeview with Showcheckboxs property option set to true.I have checked the required fields in treeview.Now i want to read this treeview & insert data to database.
Please help me........ Thanks in Advance
Regards Gurudutt
|
Title:
I can't see neither child nodes nor plus icon
Name:
Taleshi
Date:
4/3/2009 1:08:44 PM
Comment:
Dear friends, I can't see neither child nodes nor plus icon.althogh in my database there are parent nodes (Null parent) and child nodes, but just parent nodes exists without any plus. please help me soon. my email address : sd.talehi@gmail.com my code is below :
using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (! Page.IsPostBack) { PopulateRootLevel(); } }
private void PopulateRootLevel() { SqlConnection con = new SqlConnection(); con.ConnectionString = "Data Source=(local);Initial Catalog=eshop;Integrated Security=True"; SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.Text; cmd.Connection = con; cmd.CommandText = "select categoryid,categoryname," + "(select count(*) from category where parentid = category.categoryid) childnodecount " + "from category where parentid IS NULL"; SqlDataAdapter da = new SqlDataAdapter(cmd ); DataTable dt = new DataTable(); da.Fill(dt); PopulateNodes(dt , TreeView1.Nodes ); }
private void PopulateNodes(DataTable dt,TreeNodeCollection nodes) { foreach(DataRow dr in dt.Rows) { TreeNode tn= new TreeNode (); tn.Text = dr ["categoryname"].ToString (); tn.Value =dr ["categoryid"].ToString (); nodes .Add (tn ); //tn.PopulateOnDemand = ((Int32 )(dr["childnodecount"]) > 0);
if ((Int32 )(dr["childnodecount"]) > 0)
|
Title:
hi again
Name:
PoojaBindra
Date:
3/29/2009 3:27:38 AM
Comment:
Can anyone mail me the same program in vb.net plssssssssss my mail id is poojabindra @in.com
|
Title:
Its Really Great
Name:
PoojaBindra
Date:
3/25/2009 7:52:24 AM
Comment:
Plsss is there anyone ready to give me the same program in vb.net please its urgent thanks in advance
|
Title:
Thank You Very Much
Name:
Mrityunjay Ravi
Date:
3/16/2009 4:16:33 AM
Comment:
Hi, It's a excellent programming. Thank you very much for helpping.
|
Title:
Nice Article
Name:
Srinivasa Rao Alapati
Date:
3/14/2009 10:33:43 AM
Comment:
This article is very simple and working is very good
|
Title:
Excelente articulo
Name:
Diego
Date:
3/2/2009 10:18:27 AM
Comment:
Muy buen codigo, sencillo y con un excelente desempeño.
Felicitaciones
|
Title:
Expand
Name:
Jim
Date:
2/25/2009 3:45:16 PM
Comment:
Thanks for the code but have one problem. when I set the Treeview's property ExpandDepth="0" then I can't expand the tree at all. When I remove that property, tree is populated with every nodes being expanded... I like to populate the tree with ExpandedDepth as 0. I did't modify your code at all.. any idea? thanks in advance
|
Title:
hi - no performance on this code
Name:
moslem
Date:
2/1/2009 8:09:20 AM
Comment:
please contact me to order you a high level performance for this comment
moslem522@gmail.com
|
Title:
Very Good
Name:
Niranj
Date:
1/30/2009 12:01:29 AM
Comment:
I realy thanks u for help me this site... and i always use this site when i have problem
|
Title:
Wonderful
Name:
Naushad
Date:
1/29/2009 2:06:34 AM
Comment:
Its helped me thanks
|
Title:
treeview
Name:
Raghu
Date:
1/18/2009 2:37:41 AM
Comment:
Thanks for the good code. its working .but i have one small doubt " when i select one root node remaining nodes should be hide how can achive that?"
|
Title:
regarding Orientation
Name:
manoj kunmar
Date:
1/11/2009 7:46:43 AM
Comment:
how i can chage orientation of a tree view as like that menu.....i want to show my data as binary tree
|
Title:
I want The Root Level Nodes As Check Boxes
Name:
Sridhar Parshi
Date:
1/6/2009 8:17:48 AM
Comment:
i want to show the tree view like what you showned in above, but in the place of category1 2 3 i wnat show them as check boxes if any one selects that below child nodes are selected.
|
Title:
Multi column Tree Controle
Name:
Noor Arshad
Date:
1/6/2009 2:59:23 AM
Comment:
Plz tell me how can i make it multicolumn?
|
Title:
muy bueno
Name:
ivanjoseft
Date:
1/6/2009 1:25:18 AM
Comment:
Hola, en mi opinión personal, este código me ha sido de gran utilidad, fue un gran aporte, y perdona si te hablo en español, pero de igual forma fue gran aporte el que hicistes, la verdad me sirvió. GRACIAS....
|
Title:
but
Name:
Jiya786
Date:
1/1/2009 1:18:04 AM
Comment:
hey ur code working smoothly but how can i prevent from postback on TreeNodePopulate event??????its again n again doing postback the page so any1 can help me plz ???give me feedback on funs_jiya@cybergal.com
|
Title:
hi
Name:
Jiya
Date:
12/31/2008 9:21:30 AM
Comment:
onColaps i dont want postback how can i privent that post back any1 can help me plz
|
Title:
Thanks
Name:
Jiya786
Date:
12/31/2008 7:48:34 AM
Comment:
ur solution was realy help me thanks a lot n plz go ahead god bless u
|
Title:
Thanks
Name:
Fraser
Date:
12/17/2008 9:48:47 AM
Comment:
Hi - just a quick thanks for the code... very useful...
Fraser
|
Title:
Showcheckbox
Name:
Danish
Date:
12/15/2008 9:32:21 AM
Comment:
hi now im getting value of node whos hav checked=true u can see below lines of code Dim userView As TreeView = form1.FindControl("TreeView1") Dim strRights As String = "" For Each nodes As TreeNode In userView.CheckedNodes strRights = strRights & nodes.Value & "," Next TextBox1.Text = strRights but now how can i save this value in my database.means which i checked=true.how can i update anybody can help me out regarding this issue regards,
|
Title:
ShowCheckBox
Name:
Danish
Date:
12/14/2008 11:57:04 AM
Comment:
Hi, How can activate ShowCheckBox with treeview and get the value as per checkbox value True. Regards,
|
Title:
Thank you so much
Name:
suresh Dhanapal
Date:
12/12/2008 9:18:32 AM
Comment:
Hi, Thank you so much it's working super....
|
Title:
This is much simpler
Name:
Darren Schulte
Date:
12/4/2008 5:48:24 PM
Comment:
1) Create your table that contains the tree data e.g: ID,Folder key (string),Folder name (string),ParentKey(string) 2) Variables:Dim TNode As Node,Counter as Integer 3) Create first root node With TreeArg .Nodes.Clear Set TNode = .Nodes.Add(, , "t_root", "Root") end with 3) Load all records into the tree view control and make them children to root node Do Until RS.EOF Set TNode = .Nodes.Add("t_root", tvwChild, RS!FolderKey, RS!FolderName) 'Stick the parent node into the nodes tag property TNode.Tag = RS!FolderParentKey RS.MoveNext Loop 4) And now... For Counter = 1 To .Nodes.Count If .Nodes(Counter).Text <> "Root" Then Set .Nodes(Counter).Parent = .Nodes(.Nodes(Counter).Tag) End If Next Counter
|
Title:
THANK YOU!
Name:
null talent
Date:
11/18/2008 1:07:46 AM
Comment:
Works like a charm! I can't thank you enough.
|
Title:
Hey Its fantastic man, Thanks a lot
Name:
Naveen
Date:
11/17/2008 6:57:47 AM
Comment:
Hey man i was so much worried, but u made me so relaxed. Thanks a lot..
|
Title:
Thanks
Name:
Mr Quach
Date:
11/17/2008 2:58:55 AM
Comment:
Thanks u. I already fixd it. Cause from Oracle parameter
|
Title:
Help me to fix error
Name:
Mr Quach
Date:
11/10/2008 12:35:51 AM
Comment:
I use code C# to oracle but it has an error What can I fix it?
private void PopulateRootLevel() { OracleConnection objConn = new OracleConnection(@"Data Source=SALES;User Id=sa;Password=sa;"); OracleCommand objCommand = new OracleCommand(@"select id,title,(select count(*) FROM Category WHERE parentid=sc.id) childnodecount FROM Category sc where parentID IS NULL", objConn); OracleDataAdapter da = new OracleDataAdapter(objCommand); DataTable dt = new DataTable(); da.Fill(dt); PopulateNodes(dt, TreeView1.Nodes); }
private void PopulateSubLevel(Int32 parentid, TreeNode parentNode) { OracleConnection objConn = new OracleConnection(@"Data Source=SALES;User Id=sa;Password=sa;"); OracleCommand objCommand = new OracleCommand(@"select id,title,(select count(*) FROM Category WHERE parentid=sc.id) childnodecount FROM Category sc where parentID=@parentID", objConn); objCommand.Parameters.Add("@parentID", OracleDbType.Int32).Value = parentid; OracleDataAdapter da = new OracleDataAdapter(objCommand); DataTable dt = new DataTable(); da.Fill(dt); PopulateNodes(dt, parentNode.ChildNodes); }
protected void TreeView1_TreeNodePopulate(object sender, TreeNodeEventArgs e) { PopulateSubLevel(Int32.Parse(e.Node.Value), e.Node); }
private void PopulateNodes(DataTable dt, TreeNodeCollection nodes) { foreach (DataRow dr in dt.Rows) { TreeNode tn = new TreeNode(); tn.Text = dr["title"].ToString(); tn.Value = dr["id"].ToString(); nodes.Add(tn);
//If node has child nodes, then enable on-demand populating tn.PopulateOnDemand = ((Int32)(dr["childnodecount"]) > 0); // Error at this line: Specified cast is not valid } }
What can I fix it?
Thanks!
|
Title:
need 2 disable a few nodes...help!!!!!
Name:
anu
Date:
10/30/2008 9:11:24 AM
Comment:
great article .i tried it n it helped a lot for a newbie like me..but wat i need is 2 fill the tree with user roles..so some roles can only view certain child nodes..i tried 2 change the query to query by roles too but i belive it dont work that way..so i tot it would be better 2 load all nodes then iterate thru the nodes n disable the nodes which is not required for a certain role....is dat possible..can someone help me with this...
i guess il need the child node which i wanna disable den put it into a for loop right????........thanx in advance..
|
Title:
Please help the last node keep expanding
Name:
Mohamed
Date:
10/29/2008 7:01:10 PM
Comment:
First, thank you very much for dharing the code. I applied the code and it works to one exception my last node keep repeating. Here is my code and my SQL works when run outside it just retun one item but I run the example in my page it keeps adding the same node.
Thanks for your help. Imports System.Data Imports System.Data.SqlClient
Partial Class ManageCategories Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then PopulateRootLevel() End If End Sub
Private Sub PopulateRootLevel()
Dim connectionString As String connectionString = _ ConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString Dim objConn As New SqlConnection objConn.ConnectionString = connectionString Dim objCommand As New SqlCommand("SELECT Menu_id as Id, Menu_Name as Name, " _ & "(SELECT COUNT(*) FROM vw_Category_Menu M where m.parent_id= vw_Category_Menu.Menu_id) childnodecount " _ & " FROM vw_Category_Menu Where parent_id is NULL", objConn)
Dim da As New SqlDataAdapter(objCommand) Dim dt As New DataTable() da.Fill(dt)
PopulateNodes(dt, TreeView1.Nodes) End Sub
Private Sub PopulateNodes(ByVal dt As DataTable, _ ByVal nodes As TreeNodeCollection) For Each dr As DataRow In dt.Rows Dim tn As New TreeNode() tn.Text = dr("Name").ToString() tn.Value = dr("Id").ToString() nodes.Add(tn)
'If node has child nodes, then enable on-demand populating tn.PopulateOnDemand = (CInt(dr("childnodecount")) > 0) Next End Sub Private Sub PopulateSubLevel(ByVal parentid As Integer, _ ByVal parentNode As TreeNode) Dim connectionString As String connectionString = _
|
Title:
Its working
Name:
atuda2000
Date:
10/22/2008 1:29:29 AM
Comment:
Hi author.
thanks a lot. the treeview just work nicely. actually it had me write different SQL query to retrieve data from my database. but with just that, i can make good treeview.
i still not exploring the depth anyway. which im gonna do now.
thanks, author. good job. very helpful.
atuda2000
|
Title:
Child node
Name:
Vishal
Date:
10/14/2008 8:52:22 AM
Comment:
Hi This code is working fine.But when i click on last node means there no any child node i want to fetch data related to that node value id from database how i will do it.
Give me reply ASAP
|
Title:
Treeview PopulateOnDemand does not show updated results
Name:
Sat
Date:
10/2/2008 3:28:12 PM
Comment:
Hi, When I expand the node for the first time it executes the PopulateOnDemand method, but then on it is not executing that command. Now the problem is it is showing stale data(when someone changes the info listed in the treeview)
|
Title:
Display Hierarchical Data with TreeView in ASP.NET 2.0
Name:
sai vara prasada rao
Date:
9/20/2008 7:38:08 AM
Comment:
hi ,i have applied the code of tree view in my application but it is not displaying the child nodes when i click on the + (plus sign) it is not at all show the sub node .
plz kindly solve my problem . im posting my code , plz any body solve it and mail it my mail id im providing
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class Messages : System.Web.UI.Page { SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["strcon"]); protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) { PopulateRootLevel();
} } protected void TreeView1_TreeNodeCollapsed(object sender, TreeNodeEventArgs e) { } private void PopulateRootLevel() { SqlCommand cmdscrap = new SqlCommand("select senrolno,SenderName,sbatch, scenter, Semail, Ssubject,SBodytxt,Renrolno, Rname, RBatch, RCenter, REmail, Rsubject, Rbodytxt, DateMsgSend,(select count(*) FROM ibsaf_scrap WHERE senrolno=sc.senrolno) childnodecount FROM ibsaf_scrap sc where senrolno IS not NULL", con); SqlDataAdapter da = new SqlDataAdapter(cmdscrap); DataTable datable = new DataTable(); da.Fill(datable); PopulateNodes(datable, TreeView1.Nodes); } private void PopulateNodes(DataTable dt, TreeNodeCollection nodes) { foreach (DataRow dr in dt.Rows) { TreeNode tn = new TreeNode(); tn.Text = dr["sendername"].ToString(); //tn.Value = dr["senrolno"].ToString(); nodes.Add(tn);
//If node has child nodes, then enable on-demand populating tn.PopulateOnDemand = ((int)dr["childnodecount"] > 0);
my mail id is saivaraprasadarao@gmail.com
|
Title:
Display Hierarchical Data with TreeView in ASP.NET 2.0
Name:
sai vara prasada rao
Date:
9/20/2008 7:35:58 AM
Comment:
hi ,i have applied the code of tree view in my application but it is not displaying the child nodes when i click on the + (plus sign) it is not at all show the sub node .
plz kindly solve my problem . im posting my code , plz any body solve it and mail it my mail id im providing
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class Messages : System.Web.UI.Page { SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["strcon"]); protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) { PopulateRootLevel(); } } protected void TreeView1_TreeNodeCollapsed(object sender, TreeNodeEventArgs e) { } private void PopulateRootLevel() { SqlCommand cmdscrap = new SqlCommand("select senrolno,SenderName,sbatch, scenter, Semail, Ssubject,SBodytxt,Renrolno, Rname, RBatch, RCenter, REmail, Rsubject, Rbodytxt, DateMsgSend,(select count(*) FROM ibsaf_scrap WHERE senrolno=sc.senrolno) childnodecount FROM ibsaf_scrap sc where senrolno IS not NULL", con); SqlDataAdapter da = new SqlDataAdapter(cmdscrap); DataTable datable = new DataTable(); da.Fill(datable); PopulateNodes(datable, TreeView1.Nodes); } private void PopulateNodes(DataTable dt, TreeNodeCollection nodes) { foreach (DataRow dr in dt.Rows) { TreeNode tn = new TreeNode(); tn.Text = dr["sendername"].ToString(); //tn.Value = dr["senrolno"].ToString(); nodes.Add(tn);
//If node has child nodes, then enable on-demand populating tn.PopulateOnDemand = ((int)dr["childnodecount"] > 0);
|
Title:
Muchas gracias
Name:
eliud
Date:
9/17/2008 8:59:08 PM
Comment:
Mil gracias me sirvio de mucho, congrulation :)
|
Title:
it is perfect
Name:
Erol Çağlar - Aygaz IT
Date:
9/15/2008 8:20:09 AM
Comment:
it is running to Oracle.
|
Title:
VERY GOOD
Name:
Mohammad javed Comm-IT India P Ltd.
Date:
9/10/2008 3:06:15 AM
Comment:
Excellent articles..
|
Title:
Help me
Name:
Min
Date:
9/9/2008 4:56:46 AM
Comment:
Help me ~ I've got the error on my sqlcommand
@"select id,title,(select count(*) FROM SampleCategories sc WHERE parentid=sc.id) childnodecount FROM SampleCategories sc where parentID IS NULL",objConn)
da.Fill(dt); <--Error message
anybody help ~~ its made by c#
|
Title:
excellent
Name:
sanjeev
Date:
8/29/2008 5:30:28 AM
Comment:
it is very helpfull to me thanks sanjeev
|
Title:
Perfect
Name:
gaurav mehta
Date:
8/19/2008 2:20:59 AM
Comment:
nothing could better then this
|
Title:
This was great
Name:
Paul
Date:
8/14/2008 10:39:34 AM
Comment:
Fantastic. This works great. I needed to use tree view to list reports in datawarehouse by report type and this fits the bill perfectly.
|
Title:
Thanks
Name:
A.Ibrahim
Date:
8/14/2008 10:12:33 AM
Comment:
Thank you very much Teemu . it's work out
|
Title:
Excellent, gj !!!
Name:
Lancelot.Net
Date:
8/11/2008 11:13:49 AM
Comment:
Simple, easy to understand. Great article! Ty :)
|
Title:
Excellent! !!!!!!!!!!!!
Name:
Srikanta
Date:
8/8/2008 5:42:41 AM
Comment:
This is just grt article
|
Title:
Just Wow Grt !!!
Name:
Swati
Date:
8/5/2008 6:18:45 AM
Comment:
This is just grt article. It helped me to clear my concepts...
|
Title:
Excellent!
Name:
Zee
Date:
8/1/2008 7:34:05 AM
Comment:
After weeks of looking for a good, or even close TreeView example. This worked out great for me. Thanks.
|
Title:
ExpandDepth = 0
Name:
Inv
Date:
7/30/2008 10:05:01 AM
Comment:
Thanks! The most useful part was setting ExpandDepth="0" to TreeView, otherwise, very very weird behavior occured..
|
Title:
Clicking item does not post back
Name:
sangam
Date:
7/29/2008 8:24:41 AM
Comment:
It worked fine for me. Thanks. But clicking any of the item does not lead to post back. What is the reason?
Regards Sangam http://dotnetspidor.blogspot.com/
|
Title:
Data Entry
Name:
Goose
Date:
7/23/2008 9:54:26 PM
Comment:
I was able to get the treeview to populate correctly. My goal is to incorporate other data with the treeview. A data entry like form in treeview mode. Any ideas? Thanks.
|
Title:
Perfect
Name:
Bart
Date:
7/22/2008 5:26:19 AM
Comment:
Hello Teemu Keiski, This is just what I need.
Tks Best regards Bart
|
Title:
Javascript in TreeNodePopulate
Name:
olyvia
Date:
7/22/2008 4:27:57 AM
Comment:
I have a populateondemand treeview. In the TreeNodePopulate event, which is fired on clicking the nodes, I want to put a javascript function. I cannot use RegisterStartUpScript because the event does not post back. Is there any way I can put a javascript function over there?
|
Title:
devx
Name:
Panos
Date:
7/17/2008 5:46:29 AM
Comment:
Thank you so much. Exactly what I was looking for.
|
Title:
nice
Name:
chan myie
Date:
7/17/2008 4:07:13 AM
Comment:
thank u so much that is the thing i need
|
Title:
cool code
Name:
gundevar
Date:
7/16/2008 2:00:37 PM
Comment:
the c# side of the code works with only little tweaking of a local connection string. I did not change anything else. No instance failure for C# code. Thanks a lot Teemu, I've been struggling with this for 2 days. All the best!
|
Title:
Code
Name:
Teemu
Date:
7/11/2008 3:41:20 AM
Comment:
Both VB.NET and C# code were equally tested when I wrote the article and worked 100% in the scenario I used as basis. If you get such failures, your connection string is wrong, you refer wrong objects with different IDs etc. Remember, it cannot match 100% your setup, at least db connection string must be changed.
|
Title:
An error Occured in The C# Code
Name:
Rei Ayanamu
Date:
7/10/2008 11:46:19 PM
Comment:
The c# code of this program is experiencing instance failure....
|
Title:
C# Sample code
Name:
Teemu
Date:
7/8/2008 11:09:11 AM
Comment:
Use the [download sample code] link on top of the page. You'll find the code in C# and VB.NET...
|
Title:
wonderful
Name:
sartaj
Date:
7/8/2008 11:05:25 AM
Comment:
BUT I WANT THE CODE IN C#
|
Title:
TREEVIEW
Name:
SEJAL
Date:
7/2/2008 5:31:49 AM
Comment:
Very nice example....it is very useful...keep going... all the best....
|
Title:
keep state
Name:
Hi
Date:
6/27/2008 5:51:23 AM
Comment:
How to keep the treeview state after tn.NavigateUrl
|
Title:
Simple and Clear example
Name:
Mallikarjun
Date:
6/25/2008 2:23:27 AM
Comment:
Simple and Clear example and works fine
|
Title:
TreeView
Name:
Mark
Date:
6/9/2008 5:19:22 PM
Comment:
Hey, Jim thanks for the advertisement! But I'm going with something that is free, thanks. Good example by the way, Teemu!
|
Title:
tree
Name:
sesha
Date:
6/9/2008 1:37:46 AM
Comment:
usefull
|
Title:
TreeView
Name:
chandar
Date:
6/3/2008 5:25:31 AM
Comment:
Hi Teemu,
It is Fantastic and very good Examples.I appreciate u to give more idea working with that control
|
Title:
Multiple Columns
Name:
Jim
Date:
5/28/2008 6:06:22 PM
Comment:
Here is one that has multiple columns. It still has on-demand populating, postback events and hyper links too.
http://www.DigitalTools.com/GVT.aspx
|
Title:
Gridview Data Entry
Name:
hutty
Date:
5/26/2008 9:36:17 AM
Comment:
Great article. It works for me, which is phase 1. Now I need to incorporate treeview into a gridview data entry form. I had found the perfect article, but PC crashed and I can't find it again. Thanks.
|
Title:
Top to Bottom display
Name:
dosdemon
Date:
5/14/2008 3:30:17 AM
Comment:
how can we display treeview from top- to bottom rather then from left to right.
|
Title:
Displaying data with TreeView
Name:
Ryan
Date:
5/7/2008 6:33:12 AM
Comment:
This is a really good example - Im ashamed to say that I didnt even attempt to code it myself before trawling the net for a solution, but with a couple of tweaks to use Generics for the data (as I do) this worked first time!
Well done Teemu Keiski on such a well written example!
PS. (for earlier poster) there is c# code in the download example..
|
Title:
Displaying Specific data with TreeView
Name:
Cheyne
Date:
5/5/2008 7:26:38 AM
Comment:
Hi,
This code works, but displays ALL of the data on the treeview. But Id like SPECIFIC data to show, depending on who logs into the system.... how do I do that ?
|
Title:
Issue while using TreeNodecollapsed or TreeNodeExpanded events
Name:
Unlimited
Date:
4/30/2008 2:14:17 AM
Comment:
I used the code to implement the dynamic treeview and it worked fine. But when i generated the TreenodeCollapsed and TreenodeExpanded event, then on initial page load it works fine but when i clicks to expand a subfolder it calls treenodeCollapsed first before page load.
Below is my code :
Option Explicit On Option Strict On
Imports System.Web Imports System.Data Imports CHV_ITC_GilFileDetail_1_BL Imports CHV_ITC_GILFileDetail_1_DLR Imports CHV_ITC_GilFileDetail_1_DLW Imports CHV_ITC_GILFileDetail_1_EH
Partial Class TreeView Inherits System.Web.UI.Page
'Global variables Dim dsFolder As DataSet Dim dsSubFolder As DataSet Dim dtGetOverrideDetails As DataTable Dim dtResetOverrideDetails As DataTable Dim objDLR As CHV_ITC_GILFileDetail_1_DLR.DataRead = Nothing Dim objDLW As CHV_ITC_GilFileDetail_1_DLW.DataWrite = Nothing Dim objBLR As CHV_ITC_GilFileDetail_1_BL.BusinessLayer = Nothing Dim folderFlag As Integer = 0 Dim dr As DataRow
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then PopulateRootLevel() txtParentIDs.Attributes.CssStyle.Add("display", "none") End If End Sub
Private Sub PopulateRootLevel() objDLR = New CHV_ITC_GILFileDetail_1_DLR.DataRead dsFolder = objDLR.get_GSPFolderTest("0") PopulateNodes(dsFolder.Tables(0), TreeView1.Nodes) End Sub
Private Sub PopulateNodes(ByVal dt As DataTable, ByVal nodes As TreeNodeCollection) For Each dr In dt.Rows Dim tn As New TreeNode() tn.Text = dr("LASTFOLDER").ToString() tn.Value = dr("FOLDER_SEQ").ToString()
tn.NavigateUrl = "#" tn.SelectAction = TreeNodeSelectAction.Select nodes.Add(tn)
'If node has child nodes, then enable on-demand populating tn.PopulateOnDeman
|
Title:
Doing the same thing by calling a store prodedure
Name:
chame
Date:
4/28/2008 1:06:16 PM
Comment:
Hello,
I am trying to do the same thing but with ASP, there is a store procedure that's we have to do something similar that assign item from the "title" column for example a level number.
So I'm trying to do the same thing but when I call the function for this store procedure, it's display all my data as parent nodes instead of sorting it in the proper order. Do you have any suggestion of how I can get this to function properly since I am calling a stored procedure, and working with ASP?
Thanks in advance!!
|
Title:
You can achieve this with one line of code
Name:
Ralph Varjaberdian
Date:
4/23/2008 7:15:36 AM
Comment:
http://www.varjabedian.net/archive/2008/04/22/binding-asp.net-treeview-to-a-dataset-or-an-objectdatasource.aspx
|
Title:
keeeka
Name:
suribabu
Date:
4/23/2008 3:11:59 AM
Comment:
Dis really helped me a lot Thanq very very much
|
Title:
Good Stuff
Name:
Jeremy
Date:
4/17/2008 5:34:36 PM
Comment:
Hey works for me! Thanks!
|
Title:
Kalyan1982
Name:
Kalyan
Date:
4/17/2008 8:15:39 AM
Comment:
Hi,
In the above example, If I click on Category 2.1.1 on this event
Protected Sub TreeView1_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.SelectedNodeChanged
End Sub
I need to get the whole path which is
Category2/Category 2.1/Category 2.1.1
Please help!
|
Title:
It already is in C#
Name:
Teemu
Date:
4/16/2008 7:15:52 AM
Comment:
See the code download (the link is bit small on top of the article, but it is there :-) ): http://authors.aspalliance.com/joteke/treeviewv2article.zip
|
Title:
.cs file
Name:
tariq
Date:
4/16/2008 5:35:57 AM
Comment:
nice example.i m bigginer pls. can u post same in C# coding.
|
Title:
Thanks a lot...Good example
Name:
anitha
Date:
4/8/2008 9:22:35 AM
Comment:
Example is good
|
Title:
Nice Eplaination
Name:
Nikhil V.Thakre
Date:
4/4/2008 2:21:55 AM
Comment:
Explanation of treeview is very good .........
|
Title:
Great Example
Name:
Raghava.G.N
Date:
4/3/2008 5:08:43 AM
Comment:
Example was excellent by Raghava.G.N raghavagn1@rediffmail.com
|
Title:
Thanks Alot
Name:
Kishor Patil
Date:
4/2/2008 11:09:10 AM
Comment:
Thank's For This Code.... I Need It Too Much...
|
Title:
Thanks
Name:
Serkan SÖNMEZ
Date:
3/27/2008 7:07:54 AM
Comment:
that was great, Thank you Teemu Keiski
|
Title:
Great article
Name:
Juan Fco Roman Ochoa
Date:
3/12/2008 6:10:56 PM
Comment:
Thnaks man , this article is going to be very usefull for me to develop a project given to me, thanks a lot
|
Title:
Great!!
Name:
Jon
Date:
3/11/2008 9:38:20 PM
Comment:
Great Article...
I seriously don't understand why anyone would use VB, when C# is so much better.
|
Title:
very useful article
Name:
Anushka
Date:
3/11/2008 4:51:55 AM
Comment:
Such a nice article.... but can u plz tell me how to change color of a selected node...
|
Title:
Josh
Name:
dilshad
Date:
3/10/2008 8:07:04 AM
Comment:
Thanks....
|
Title:
bindind TreeView with datagrid
Name:
Nishant Singh
Date:
3/5/2008 12:35:49 AM
Comment:
Teemu, that was great. can u throw some light on binding treeview control with a datagrid
|
Title:
Superb Work
Name:
Srinivasan
Date:
2/28/2008 11:27:04 PM
Comment:
t tried the same concept for more than two concepts, but after seeing r code, i got the idea and implemented it...thank u so much.HATS OFF to ur work...
|
Title:
Such a Nice Code
Name:
Jay Mehta
Date:
2/20/2008 1:57:54 PM
Comment:
Such a Nice code that helps me lot. Do you have this type of code for menu control or is it same for menu control?
Thank you
|
Title:
Node refresh
Name:
AP
Date:
2/20/2008 1:39:33 PM
Comment:
Thank you for posting this - it is extremely helpful!
I was wondering how would I be able to extend this further so if I were to add/delete a node in the database via a webform, the parent node of the TreeView would automatically refresh?
|
Title:
Excellent work! - Light Waight
Name:
Venkat Rao Konka
Date:
2/16/2008 12:14:46 AM
Comment:
Nice and simple Snippet. Right usage of Tree View Control. Hope s this gives dare to tree view by programmers. All the Best. Thank You Venkat Konka
|
Title:
Please help!
Name:
Vansana
Date:
2/7/2008 2:28:53 PM
Comment:
Hi all, Greate work!. I got question similiar to the last post. How do I populate another sub under each Category? Say if I have products assiciated with earch category. Hope this making sense.
Thanks inadvance
Vansana
|
Title:
Excellent work!
Name:
Jara
Date:
2/7/2008 3:30:11 AM
Comment:
This is very nice work!!! but how do I associate the categories or subcategories with products to make it like real world stuff? For example if I have CategoryID link to Products table as foreing key.
Thank you very much. Jara
|
Title:
very good
Name:
Ezhil
Date:
2/5/2008 7:15:30 AM
Comment:
Hi, i searched lot for the tree view, It is the best stuff thanks a lot
|
Title:
Nice post
Name:
kalyan
Date:
2/4/2008 4:13:25 PM
Comment:
Your post solved my problem.
|
Title:
Very good stuff
Name:
marty
Date:
2/3/2008 4:59:48 AM
Comment:
i am a newbee and i search a long time and here i found the right stuff very good and thank you :-)
|
Title:
Great
Name:
dammyTosh
Date:
1/24/2008 5:22:43 PM
Comment:
Men u are great it simply solved my 1 week head ache.
|
Title:
See docs
Name:
Teemu
Date:
1/24/2008 1:44:24 AM
Comment:
From: http://technet.microsoft.com/en-us/library/e8z5184w.aspx
Using the TreeView Control with UpdatePanel Controls UpdatePanel controls are used to update selected regions of a page instead of updating the whole page with a postback. The TreeView control can be used inside an UpdatePanel control with the following restrictions:
TreeView callbacks must be associated with asynchronous postbacks, or callback event validation will fail. When you set the PopulateOnDemand property of the TreeNode controls to true, callbacks are enabled. You can use one of the following approaches to ensure that TreeView callbacks work with the UpdatePanel control:
If the TreeView control is not inside an UpdatePanel control, disable callbacks on TreeNode controls that are not part of an asynchronous postback. To do this, set the PopulateOnDemand property to false.
Programmatically refresh all controls that register callbacks during the asynchronous postback. For example, you can place the TreeView control inside an UpdatePanel control. The TreeView control does not have to be in the UpdatePanel control where the asynchronous postback originates, as long as the UpdatePanel control that contains the TreeView control is refreshed.
You must apply styles by using a reference to a Cascading Style Sheet (CSS) class. For example, instead of setting the NodeStyle property by using a property-subproperty attribute, set the style by using the property-CssClass attribute. Similarly, when you use the NodeStyle template to set the style, use the CssClass attribute of the template.
The EnableClientScript property must be true (the default value). In addition, if callbacks are enabled for the TreeView control, you cannot change the EnableClientScript property between asynchronous postbacks.
|
Title:
Integrate with Ajax Issue
Name:
Hardy Wang
Date:
1/23/2008 8:32:47 PM
Comment:
I tried this solution, it works perfectly. Then I tried to embed treeview into a ajax updatepanel, now I comes with some problem
I expand one node, then select some other node (select not expand), by this time TreeNodePopulate and SelectedNodeChanged both will be fired, and then keep clicking on this single node (already selected), TreeNodePopulate envent will be fired again and again which causes sub nodes of first expanded node keep grouping and duplicating.
If I remove updatepanel to use regualar postback mode, I don't have this issue.
Any idea?
|
Title:
I Need Some Other Help
Name:
subhranshu
Date:
1/23/2008 12:19:01 AM
Comment:
How can i show the system data in treeview control... suppose i want to show all c:/ documents..that means c:/ should be the parent one and rest sub-folders should come in chlid like and so on.. and please give the code in c#
|
Title:
I Need Some Other Help
Name:
Subhranshu
Date:
1/23/2008 12:17:03 AM
Comment:
How can i show the system data in treeview control... suppose i want to show all c:/ documents..that means c:/ should be the parent one and rest sub-folders should come in chlid like and so on..
|
Title:
V Good
Name:
Carl
Date:
1/10/2008 5:19:55 PM
Comment:
I was up and running within 2 minutes. Thanks for the excalant example. simple and easy to follow.
|
Title:
Fine
Name:
Rajkumar
Date:
1/4/2008 12:08:37 AM
Comment:
i want to display the data on same window by clicking tree node.so how is possible..can i know that type of code...
|
Title:
its fine,but i want to explorer type treeview to display the data on the same window by clicking on treenodes
Name:
anu
Date:
12/28/2007 12:03:55 AM
Comment:
its fine,but i want to explorer type treeview to display the data on the same window by clicking on treenodes
|
Title:
its fine,but i want to explorer type treeview to display the data on the same window by clicking on treenodes
Name:
anu
Date:
12/28/2007 12:02:25 AM
Comment:
its fine,but i want to explorer type treeview to display the data on the same window by clicking on treenodes
|
Title:
Nods are not accessable, after populating with the help of a button event
Name:
Chandrajit Samanta
Date:
12/20/2007 2:09:31 AM
Comment:
I am using ASP.NET 2.0 Treeview control. During initial page load treeview is not populated. Onclick of a button treeview is papulated. But populating I am trying to access all those nodes from codebehind, using another button click event in the same page. But in the second button click event treeviev control is showing empty, in codebehing, where as the page is still displaying all those populated node. Please tell me how to access all those node from codebehind...
Chandrajit Samanta chandrajit.samanta@gmail.com 9986044300, Bangalore , India
|
Title:
Works but need another help
Name:
Rey
Date:
12/18/2007 12:38:15 PM
Comment:
As I said, I'm new to Expression Web and ASP (though I know VB6 and VFP, and I already implement Treeview in different way).
I was able to avoid re-displaying the treeview everytime clicking node by adding this code in the populatenodes, just after nodes.Add(tn)
tn.NavigateUrl = "javascript:void(0)"
Now, my problem was when you select another node, the previous node change the color to like disabled (its look like revisited link).
My another problem is to get the value of the selected node as I would like to pass the value to open a page browser to display information of the selected node...
Looking forward to any help and link that I could resolve my problem.
Thanks again for the great code!
Rey
|
Title:
It works fine but I need another help
Name:
Rey
Date:
12/18/2007 2:39:13 AM
Comment:
First of all, thank you so much for the sample code. It help me to save time. I am very new to web thing.
Can you please extend your help to me for 2 things that I need to implement.
1. Can the treeview be populated before the page display? Same as the other comment below?
2. In node click event, I need to pass the ID# (not the newid()) so I can open a browser page that contains the information of the node click.
Thanks you in advance.
|
Title:
Node not a member of system.args
Name:
jip
Date:
12/11/2007 10:50:56 PM
Comment:
inline " PopulateSubLevel(CInt(e.Node.Value), e.Node) " it gives me an error message 'Node is not a member of System.Args' can any one him me please....
|
Title:
Wonderful
Name:
Your friend
Date:
12/10/2007 7:07:52 AM
Comment:
Thanks................. Greate job
|
Title:
Thanx
Name:
Siju George
Date:
12/6/2007 3:30:18 AM
Comment:
Thanx so much for this help
www.codepal.co.in
|
Title:
Great article
Name:
Bino
Date:
12/6/2007 1:25:57 AM
Comment:
Nice article, well explained
www.codepal.co.in
|
Title:
Nested Gridview footer total by using javascript
Name:
ram
Date:
12/5/2007 1:34:08 AM
Comment:
I want to display Nested Gridview footer total by using javascript .i am 2 gridviews(gvEmployee(Empcode,sal -fields)(gvDepartment(Deptcode,sal-2fields).I want to display both totals in separate .sal is template field. its v.v.urgent.
thnx
|
Title:
Excellent Example - Need some enhancement
Name:
Cherry
Date:
12/3/2007 12:16:24 PM
Comment:
Above example is working fine. Can you let me know if i want, How to add root node (category 1, category 2, ...) statistically(i.e., not from the database table) along with dynamic (from dataset) parent & child node population?
|
Title:
Sample Code
Name:
Teemu
Date:
12/3/2007 7:35:02 AM
Comment:
See the "Download Sample Code" on top side of the page. There's both C# and VB.NEt code.
|
Title:
C#
Name:
Sujith
Date:
12/3/2007 7:31:19 AM
Comment:
Can you Give me the code for the same in C# asp.net
|
Title:
Great Job!
Name:
Tim
Date:
11/29/2007 1:50:24 PM
Comment:
Great article. I was up and running within 5 minutes. Thanks for being succinct and supplying the code examples.
|
Title:
Anyone get 'Object Expected' error ?
Name:
jake
Date:
11/21/2007 1:11:40 PM
Comment:
this works great, but I can't expand/collapse as the generated javascript causes an 'object expected' error.. anyone have a solution to this ?
|
Title:
Too good for developers
Name:
Chetan Nagar
Date:
11/16/2007 12:51:01 AM
Comment:
This is best implementation of treeview using codes.
|
Title:
Greate work
Name:
Mem
Date:
11/11/2007 11:12:39 AM
Comment:
Well done! simple and efficient. now i have to figure how to retain the selected node state 10X
|
Title:
Thanks, It's a good code :)
Name:
Roberto Londono
Date:
11/7/2007 4:13:35 PM
Comment:
Hey Teemu, Very nice code, It work how exsample in my application very well. If you need reference. Roberto Londono Echeverry Washington State University Education and Public Media rlondono@wsu.edu
|
Title:
Thanks
Name:
Susant
Date:
11/7/2007 5:28:19 AM
Comment:
Hello..
Your article Help me
|
Title:
Where is
Name:
Teemu
Date:
11/5/2007 4:36:06 AM
Comment:
2.1 is title, not parentid. Otherwise, I don't understand what you're referring to. The code sample above contains tested code, which is emphasized on the article examples, and it works just fine with no overflows.
|
Title:
Thanks, It's a good code :)
Name:
Yebay
Date:
11/5/2007 2:17:46 AM
Comment:
This one is a good code, heheheh
but if the parentid is an integer type with the value like 2.1, 2.1.1, 2.1.1.1 it will return 2 to parentid and caused stackoverflow exception, oohohoho so change it to string will solve a problem.
|
Title:
Postback
Name:
Teemu
Date:
11/2/2007 9:31:27 AM
Comment:
As I write in the article: "Note that clicking on the node does cause a postback because I haven’t modified the select action of the populated tree nodes from the defaults. "
|
Title:
A Problem in you treeview
Name:
Ashrafali
Date:
11/2/2007 9:01:29 AM
Comment:
Hello Brother, Thankyou for your solution. It is nice and very helpful to me. But I face one problem. When I click on node's text it got postback and load same data once more.
So please check it and guide me proper solution
thanking you Ashrafali
|
Title:
On Page Load all the Nodes should be expanded ?
Name:
Sehul Soni
Date:
10/30/2007 10:51:56 AM
Comment:
Hi,
This is nice example. Thanks a lot. It helped me lot. Is it possible that at Page Load automatically all the Nodes expanded ? One more bug i found is when I am clicking on Sub Node it is creating whole tree again and again.
help me ?
Reply on sehulsoni@gmail.com
Thanks Sehul
|
Title:
Perform ALL roundtrips on page load first?
Name:
wizkidd
Date:
10/29/2007 12:24:25 AM
Comment:
Is it possible to alter the code so that the tree is entirley populated before at page load? This way we wouldnt have to invoke OnTreeNodeExpanded="TreeView1_TreeNodePopulate" ?? If this was possible, it would eliminate the annoying postback which I find the only poor thing.
Anyone wanna give eliminating the postback a shot?
- WizzKidd
|
Title:
Great Program
Name:
Amit Jha
Date:
10/26/2007 8:35:49 AM
Comment:
Really this program helped me. I am so oblige to you.
|
Title:
TreeView
Name:
CK
Date:
10/5/2007 4:04:31 PM
Comment:
Great Article for displaying data!
(1)Is there a way to display the childnode data onclick of it's parent?
(2) Then I insert all the user's choices in a related table using the following fields.
Projid Type Description
100 Goal PI-1 Blah blah goal choice 1
100 Objective PI-1.1 Blah Blah objective a
100 Goal TI-3 Blah Blah goal choice
100 Objective TI-3.1 Blah Blah objective a
100 Objective TI-3.2 Blah Blah objective b
100 Objective TI-3.3 Blah Blah objective c
After the user submits there data I give a web page which displays everything they entered. I show a Treeview which displays only the Goals and Objectives they selected, but it lists ALL the objectives for each goal. I would like it to show only the objectives with its master goal.
Any help is appreciated! Thank you.
|
Title:
OnTreeNodeExpanded="TreeView1_TreeNodePopulate"
Name:
D.Bopp
Date:
9/28/2007 10:55:47 AM
Comment:
Good piece of code, thanks.
I had to add OnTreeNodeExpanded="TreeView1_TreeNodePopulate" to the TreeView to get it run properly. Took me a while to find that bug.
|
Title:
Tree View
Name:
Adarsh Tated
Date:
9/27/2007 3:04:21 AM
Comment:
Hi I am Adarsh I am Not Able To understand how to populate data from sql server on tree view this Article give me a full support Thanks To Lot
|
Title:
refresh
Name:
dany
Date:
9/25/2007 7:22:10 PM
Comment:
how can i refresh the tree when i updatae my db the problem is when i use the functuion PopulateRootLevel() i get another tree view
|
Title:
Awesome Article
Name:
SM
Date:
9/5/2007 9:14:44 AM
Comment:
...this helped me a lot!
|
Title:
help me in implementing tree view for MS CRM
Name:
Suresh Chinna
Date:
9/4/2007 6:27:33 AM
Comment:
Hi friends,
Can anyone suggest me how to implement treeview control in our aspx page( which is extension of MS CRM application) with the datas across different tables, where datas being stored in MS CRM Database
help me out
PS; give some sample codes for implementing
|
Title:
Please help me!
Name:
Sriram
Date:
8/25/2007 4:54:29 AM
Comment:
Can you suggest me a way of getting the check boxes which are checked in the treeview using the above sample as reference?
|
Title:
Gr8 Article!!!
Name:
Sriram
Date:
8/25/2007 4:52:36 AM
Comment:
This was a great article!!!Thanks a lot! I have a similar requirement and was struggling to get this done!This perfectly works!
|
Title:
Doesn't work in Firefox in my case
Name:
Dimitar Kyuchukov
Date:
8/22/2007 6:06:30 AM
Comment:
The menu works perfectly well in IE but not in Firefox/1.5.0.12. Still Your article is really helpful.
|
Title:
Good One,very Usefull
Name:
Anish V S
Date:
8/18/2007 3:56:32 AM
Comment:
Hi Thanks for your code
|
Title:
Its Really GOOOOOoooooooooooooOOOOOOOD
Name:
ViREnDRa KumAr KohlI
Date:
8/10/2007 4:52:00 AM
Comment:
Hi, Its Really GOOOOOoooooooooooooOOOOOOOD Code, Outstanding................. Very Helpfull to mEeeeeee
|
Title:
New Node
Name:
Claf
Date:
8/8/2007 10:45:02 AM
Comment:
Who insert/delete/update nodes?
|
Title:
Nice One
Name:
Santosh
Date:
7/31/2007 8:41:17 AM
Comment:
nice one .it help me a lot
thanks
|
Title:
Sir
Name:
Crabs
Date:
7/31/2007 6:38:35 AM
Comment:
THANKYOU I love this code so much it is my new girlfriend.
|
Title:
Tnx Alot
Name:
Lior Cohen
Date:
7/28/2007 11:42:04 PM
Comment:
I was strongeld with the treeview for days! this code is perfect , no other words! you trolly help me out!
|
Title:
Tree Node
Name:
Shuchi
Date:
7/19/2007 1:21:29 AM
Comment:
It is Very Good Example
Thanks
|
Title:
TREE nODE
Name:
Rahul P
Date:
7/5/2007 7:39:23 AM
Comment:
Perfect Example Thanks
|
Title:
I get duplicate data on the tree
Name:
Allan
Date:
7/3/2007 7:46:29 PM
Comment:
Hey, thanks for the tutorial, I tried running your code with a stored proc as the sql command argument. In my SQL management studio, I get the correct number of returns. On the tree view, I get exactly 2 sets of them. Where could I have gone astray. I didn't make any other mods except replacing your inline sql with a sproc.
|
Title:
Works good - Save State of Tree?
Name:
James
Date:
6/28/2007 3:01:55 PM
Comment:
This worked out for me. Is their a way to save the state of the tree when you are dynamically populating the treeview, with ought having to iterate through all the nodes? Or can someone point me to a good article that explains how to do this? Thanks
answer to: diablo64@gmail.com
|
Title:
Error if the child node is clicked.
Name:
jossy
Date:
6/28/2007 2:24:47 AM
Comment:
HI its a good code. I am able to populate the tree but if i click the node one more time null point error is comming.
|
Title:
this does not work
Name:
Ritesh
Date:
6/25/2007 9:00:19 AM
Comment:
i had tried the same tutorial but when i click on other controls it still populates tree with same child node again & again what can be the solution...
|
Title:
Image
Name:
Teemu
Date:
6/20/2007 12:04:58 PM
Comment:
Shouldn't setting image for a TreeNode be as simple as setting the ImageUrl property to point to the image? You can also set specifically ExpandImageUrl, CollapseImageUrl, NoExpandImageUrl (though these three are given at the TreeView)
|
Title:
if use image to create organization chart .Is it possible?
Name:
lermpon
Date:
6/20/2007 3:39:44 AM
Comment:
if use image to create organization chart .Is it possible?
|
Title:
Toggle Root/Parent Nodes Text
Name:
Adolph Key
Date:
5/26/2007 7:38:48 AM
Comment:
Hi Teemu, great code. I wanted to know how can I get the text for the Root and Parent Nodes to Toggle just like the expand(+)/collapse(-) images?
|
Title:
Fill Hierarchichal data in tree view
Name:
Leela Pradeep Reddy
Date:
5/13/2007 3:53:37 AM
Comment:
Hi it's Very nice Example for Tree view. Thank you very much
|
Title:
Fill Hierarchichal data in tree view
Name:
Puneet Khurana
Date:
5/10/2007 5:12:18 AM
Comment:
it is very nice example of populating a asp.net treeview with hierarchichal data.
|
Title:
Any Code in vb.net
Name:
Riyas Thangal P S
Date:
4/25/2007 7:13:23 AM
Comment:
Hi Any code for displaying hierarchial data in vb.net please send me to riyasthangal@yahoo.com...Any help would be greatly appreciated. thanks
|
Title:
Selected
Name:
phlipdawg
Date:
2/19/2007 10:39:40 AM
Comment:
Hi, I am trying to set a flag when I select a node. I've tried using the Selected property, but it always comes back as "false" I'm trying to use one of the noads as a logout
any help would be greatly appreciated. thanks.
|
Title:
tree view
Name:
Rakesh
Date:
2/15/2007 2:08:58 AM
Comment:
there i have used the teree view in asp.net2003 but new i am converting this project .net 2005 so it gives th error in following......... System.Web.UI.WebControls.TreeNode tnParent=new System.Web.UI.WebControls.TreeNode(); // tnParent.Type="P";//error tnParent.ID=dr/error[0].ToString(); tnParent.Text=dr[2].ToString(); tncNode.Add(tnParent);
how can i remove this pls mail me on rakes.j@panteq.com
|
Title:
add remove node
Name:
fariba
Date:
2/10/2007 5:57:58 AM
Comment:
how can add romove a node and refresh to show new nodes or remove nodes in tree.
|
Title:
Thanks
Name:
Alex
Date:
2/9/2007 2:44:15 PM
Comment:
Great code, up and running in no time.
|
Title:
NavigateUrl
Name:
Teemu
Date:
2/4/2007 1:46:06 AM
Comment:
NavigateUrl is property of TreeNode, just like Text and Value are. My sample already sets Text and Value, so adding NavigateUrl to thje process is very trivial (one more property to set)
|
Title:
treenode
Name:
phlipdawg
Date:
2/2/2007 2:50:27 PM
Comment:
or is there a way to use the DB to assign the url?
|
Title:
treenode
Name:
phlipdawg
Date:
2/2/2007 2:49:11 PM
Comment:
Could you post a short example, my apologies, I'm very new to this
|
Title:
URL
Name:
Teemu
Date:
2/2/2007 12:27:35 PM
Comment:
Set the NavigateUrl property of a TreeNode. It puts the node in navigation mode (when clicked you're redirected to the URL).
|
Title:
Link Nodes to a url?
Name:
phlipdawg
Date:
2/2/2007 10:20:18 AM
Comment:
This is great, but how do you link the nodes to URL's?
|
Title:
Use Code Download
Name:
Teemu
Date:
1/31/2007 9:09:48 AM
Comment:
The "Download Sample Code" link at top of the article might help. :-)
There's the source both in VB and C#.
|
Title:
Convert code to C#
Name:
zia Ul Hassan
Date:
1/31/2007 5:38:40 AM
Comment:
I am trying to convert this code to C#. I got stuck at this point Handles TreeView1.TreeNodePopulate
any idea?
|
Title:
Treeview Control
Name:
Henning
Date:
1/27/2007 6:46:41 AM
Comment:
Thanks, I saved a lot of time with this codesample :-)
|
Title:
Treeview controls
Name:
Charlie R
Date:
1/14/2007 10:14:40 PM
Comment:
Many thanks Teemu! I had tried many other ways of doing this and was getting tired and then your code worked the very first time. Thanks again, Charlie
|
Title:
Excellent
Name:
Irfan
Date:
12/31/2006 5:34:44 AM
Comment:
Very Excellent !! Keep it up
|
Title:
TGridView in TreeNode
Name:
Teemu
Date:
12/6/2006 11:05:48 AM
Comment:
Yes, it is. You can use techniques demonstrated in following blog post to render a grid in TreeView: http://weblogs.asp.net/dannychen/archive/2006/01/25/436454.aspx
If you use a GridView as instantiated control to get grid-like output, there can be certain challenge with state management side. You probably need to create custom TreeView as well to deal with that side. However, just rendering a grid/table with given HtmlTextWriter within TreeNode should be easy task.
|
Title:
Treeview controls
Name:
ravi
Date:
12/6/2006 9:49:05 AM
Comment:
Truly great stuff.
Is it possible to bind a gridview in treeview?
|
Title:
Link problem
Name:
Stig Barnney
Date:
12/4/2006 4:05:54 AM
Comment:
Hi, nice code and well explained.
I also have this problem, when I link each SubCategory to an aspx page, the tree closes back to root.
Thanks
Barnney stig@barnney.dk
|
Title:
Treeview Controls
Name:
Adityan
Date:
11/13/2006 1:56:22 AM
Comment:
very useful! Great article..
|
Title:
Treeview controls
Name:
Ranu
Date:
11/7/2006 6:34:51 AM
Comment:
Hi, Code may be useful ,but i tried to run this code n its not working.The query which u have used is not clear.
select id,title,(select count(*) FROM SampleCategories " _ & "WHERE parentid=sc.id) childnodecount FROM SampleCategories sc where parentID=@parentID
|
Title:
Tanks
Name:
Bulent Cavan
Date:
11/6/2006 12:18:59 PM
Comment:
Thanks, :)
|
Title:
Nice code
Name:
Marko
Date:
11/3/2006 9:38:12 AM
Comment:
Hi, nice code and well explained many thanks.
I have the same problem as a post earlier but could see a response.
Basically
when I link each SubCategory to an aspx page, the tree closes back to root. Any help would be welcome
Thanks Marko
|
Title:
Treeview controls
Name:
Cem Aksoy
Date:
10/27/2006 10:50:51 AM
Comment:
Impressive, it's quite explicit and useful.Thanks for your great article.In the meanwhile Adnan, dont look up for hairy,possible you are Turkish and you understood me ;)
|
Title:
Treeview controls
Name:
Alex
Date:
10/20/2006 10:41:11 AM
Comment:
Thank you, I try it and its help me. But, if I open page vith TreeView1.visible=false, and on Button.Click I make TreeView.visible-true subcategory dosn't open. Some body know why? Thanks
|
Title:
Great Code
Name:
Sebastian
Date:
10/18/2006 11:43:50 PM
Comment:
Hi, it's great!!!! But I have a problem and it's when I link each SubCategory to an aspx different, the tree goes back and it appears closed from the root... I don't know what to do.... please Heeeelp!!!! Sorry for my english I'm from Argentina, and I don't use writting in english... :) Pls, answer to seba_la_x@yahoo.com
|
Title:
Thanks
Name:
John
Date:
10/15/2006 10:23:41 PM
Comment:
This is awesome. Thanks!
|
Title:
Treeview controls
Name:
Joey
Date:
10/10/2006 6:26:24 PM
Comment:
Thank you so much for this! I wish there were lots of good information out like this on the Internet! :)
|
Title:
Treeview Controls
Name:
Joyce and Renuka
Date:
10/6/2006 5:35:09 AM
Comment:
Good stuff!!!!! We have a tree view which has a multilevel hierarchy Project-A Estimate-A Area-A Area-B System 1 System 2 Product 1
with least database trips how can we get this hierarchy?
|
Title:
Tree View Control
Name:
Mohammed Ghouse Barq
Date:
9/27/2006 1:22:29 AM
Comment:
This is excellent, I really like approach.
|
Title:
waooooo
Name:
Abdulla Hussein
Date:
9/25/2006 3:36:33 PM
Comment:
Thank you, I try it and its help me
|
Title:
Treeview Controls
Name:
Uday
Date:
9/21/2006 5:11:26 AM
Comment:
Thanks very much for this simple and precise article that explains the concept to the point. Awesome!!
|
Title:
Re: Treeview controls
Name:
Teemu
Date:
9/4/2006 3:04:25 PM
Comment:
Lata,
TreeView in ASP.NET is in System.Web.UI.WebControls namespace (System.Web.dll assembly)
|
Title:
Re: Treeview
Name:
Teemu
Date:
9/4/2006 3:03:03 PM
Comment:
Adnan, you need first think does representing data in TreeView make sense. Basically if you have 3 or 4 tables and it's direct parent-child relationship, idea is eseentially the same as with self-referencing table (and yes, it can make sense). First get the root level, then query for the next and so on. Using separate tables basically makes the levels in the tree fixed, as well as queries getting specific levels.
|
Title:
Re: Treeview Control
Name:
Teemu
Date:
9/4/2006 3:00:06 PM
Comment:
sc is just shortcut to SampleCategories. See the "FROM SampleCategories sc" in where clause. Essentially it's using a subquery to get count of child nodes for a parent node and sc is used to reference the parent table from the subquery.
|
Title:
Treeview Control
Name:
Ren
Date:
9/4/2006 1:48:12 PM
Comment:
I tried the code and it worked, thanks. I have used basic query strings before, but nothing like this. What does sc.id represent? Also, what is this "sc" between SampleCategories and WHERE for?
select id,title,(select count(*) FROM SampleCategories " _ & "WHERE parentid=sc.id) childnodecount FROM SampleCategories sc where parentID IS NULL
Thanks,
-Ren
|
Title:
Treeview
Name:
Adnan
Date:
8/29/2006 8:56:26 AM
Comment:
Let suppose if i have many (3-4) tables in SQL server 2005 linking with each other, and i want to disply all records in treeview what i should i do ?
|
Title:
Treeview Controls
Name:
Mali
Date:
8/27/2006 4:56:30 PM
Comment:
This is a perfect reference for the dynamic treeview population. Thanks for everyone who contributes to this code.
|
Title:
Treeview controls
Name:
Lata
Date:
8/22/2006 5:32:13 PM
Comment:
Good one!! I m getting an error though "Treeview doesnt exist in the current context". Am I missing any namespace? Also is there a way to have datagrid itself in the child node?
|
Title:
Too many round-trips
Name:
Deepak Aggarwal
Date:
8/17/2006 7:41:38 AM
Comment:
Hi Truly a great stuff. However, 'n ' database calls will be made where n is the number of nodes having child element. If 'n' is too big, this application will consume a lot of memory. Cant you retrive the entire structure in one go, save it in xml and manage on client side? please suggest code for this.
|
Title:
Treeview controls
Name:
Tim
Date:
8/3/2006 6:23:18 PM
Comment:
Brilliant!! Thank you so much for a nicely written and explained solution. After a few changes to field names and database connection strings, it worked with the table I have already populated with data.
|
Title:
Treeview controls
Name:
Sandeep
Date:
7/21/2006 1:51:29 AM
Comment:
This is one of the nice code..........
|
Title:
Treeview Controls
Name:
Paul
Date:
7/14/2006 2:55:28 PM
Comment:
Thank you very much. I just started with ASP.NET and I've been looking for days for a way to populate the treeview from a DB. The problem was always that the code was way over my head and they didn't explain it very well. More like "Here's the code. Enjoy". You took the time to explain all the steps and I'll be able to use this example with my application.
|
Title:
Treeview controls
Name:
Rincy
Date:
7/10/2006 7:22:05 AM
Comment:
This coding was very useful.
|