Get All parents of selected nodes in asp.net 2.0 - Ted Ngo

13-Mar-07 04:22:56
Hi All,

I am using treeview control in asp.net 2.0.
this is my treeview:

ZZZZZ
NNNNNN
HHHHHHH
KKKKKKK
AAAA
BBBB
CCCC
DDDD
LLLLL
11111
22222
333333
XXXXX
12345
5678
YYYYY

if I selected "DDDD" node, I would get to get all the parents text of
the "DDDD" node
I want to get back "CCCC", "BBBB", "AAAA"

I am using this to get "DDDD" node text back "tv.SelectedNode.Text"
And I am using this to get "CCCC" node text back
tv.SelectedNode.Parent.Text but I am not sure how to get BBBB and AAAA
text back.

Please help.

Thanks in advance
reply
 
 

Get All parents of selected nodes in asp.net 2.0 - John

13-Mar-07 05:19:04
Hello Ted,

If "DDDD" is selected then:
tv.SelectedNode.Parent.Text returns "CCCC"
tv.SelectedNode.Parent.Parent.Text returns "BBBB"
tv.SelectedNode.Parent.Parent.Parent.Text returns "AAAA"

Is that what you're after?

Best regards

John
reply
 

Get All parents of selected nodes in asp.net 2.0 - Ted Ngo

13-Mar-07 08:43:19
Yes, that is what I want, Thanks. But the problem is that the nodes
not always 4 levels, it different from nodes to nodes, I mean some
time it 5 levels, sometime 2, some 10 levels.
So I do it programmaticly.

I try this to get all the values of the nodes selected. (all it
parents)
string tst = tv.selectednodes.valuepath.
now which the values, can I get the nodes text. How.

Thanks
reply
 

Get All parents of selected nodes in asp.net 2.0 - John

14-Mar-07 07:52:05
Do you mean:

tv.SelectedNode.FullPath

?

John
reply
 

Get All parents of selected nodes in asp.net 2.0 - Ted Ngo

14-Mar-07 09:38:50
Here is path of my code:

protected void TreeNodeChanged(object sender, EventArgs e)
{
string [] nodepath;
string txt;
string txtofnodeselct;

txtofnodeselct = tv.SelectedNode.Text

txt = "";
nodepath = tv.SelectedNode.ValuePath.Split('/');

Now ny now nodepath have these nodes values:
nodepath[0] = "123"
nodepaht[1] = "456"
nodepath[2] = "893"
nodepath[3] = "442"
and so on

//now I loop through nodepath
foreach (string str in nodepath)
{
//my str will contain the value of the nodes
//How can I get the text of that node which the value node in the
//Please help.

}

}

Thanks
reply
 
SQLConnection' is not defined
promotion
Silverlight    WPF    WCF    WWF    LINQ   
JavaScript    AJAX    ASP.NET    XAML   
C#    VB.NET    VB 6.0    GDI+    IIS    XML   
.NET Generics    Anonymous Methods    Delegate   
Visual Studio .NET    Expression Blend    Virus   
Windows Vista    Windows XP    Windows Update   
Windows 2003 Server    Windows 2008 Server   
SQL Server    Microsoft Excel    Microsoft Word   
SharePoint    BizTalk    Virtual Earth   
.NET Compact Framework    Web Service   

"Everything" RSS / ATOM Feed Parser
How to send and receive messages through message queuing in .Net
How to Read text file as database
SQL Server 2005 Paging Performance Tip
Display code of web page.
Fully Scalable Excel File Importer class for .net using Microsoft Jet driver
Generic Chart Color Manager class that can be used for any charts
Helper class to style the infragistics wingrid
Using Reflection to detemine as Assembly Info in and out.
Helper class to play with Window (Owners and position)
Resolving displayname from the culture using the XmlLanguage and LanguageSpecificStringDictionary class