473,382 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Expand TreeView programmatically (ASP.NET 2.0)

Hi,

I'm trying to expand a special Node of my TreeView from Codebehind.
I have a TreeView on a page for navigating to another site. On the other
tsite here is the same TreeView more precisely a new TreeView with the same
nodes ;)
So I would like to keep the expanding state of the first Tree for the second
one on the next page. At least the last selected node (path will be saved in
query string) should be expanded.

Remarks: The TreeView is rendered in an IFrame to enable scrolling. Maybe
there might be another solution. Let me know if someone knows ;)

Here is what I tried:

protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{
//Populate the Tree
TreeView1.Nodes.Add(TopicFactory.PopulateTopicTree Nodes());
TreeView1.Target = "_parent";

if (Request.QueryString["path"] != null)
{
//path for the node is in the query string
string path = Request.QueryString["path"];
TreeNode selected = TreeView1.FindNode(path);

if (selected != null)
{
//expand the node belonging to the given path
selected.Expand();
}
}
}
}

Finding the node is no problem. But it seems the method Expand() has no
effect :(

I hope someone can help.

Greetings

Karim
Nov 19 '05 #1
4 10112
Would this [1] help?
See also...
google: postbackurl site:msdn2.microsoft.com

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

[1] http://msdn2.microsoft.com/en-us/lib...us,vs.80).aspx

"Karim El Jed" <no****@netcreate.de> wrote in message
news:eH**************@TK2MSFTNGP10.phx.gbl...
Hi,

I'm trying to expand a special Node of my TreeView from Codebehind.
I have a TreeView on a page for navigating to another site. On the other
tsite here is the same TreeView more precisely a new TreeView with the
same nodes ;)
So I would like to keep the expanding state of the first Tree for the
second one on the next page. At least the last selected node (path will be
saved in query string) should be expanded.

Remarks: The TreeView is rendered in an IFrame to enable scrolling. Maybe
there might be another solution. Let me know if someone knows ;)

Here is what I tried:

protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{
//Populate the Tree
TreeView1.Nodes.Add(TopicFactory.PopulateTopicTree Nodes());
TreeView1.Target = "_parent";

if (Request.QueryString["path"] != null)
{
//path for the node is in the query string
string path = Request.QueryString["path"];
TreeNode selected = TreeView1.FindNode(path);

if (selected != null)
{
//expand the node belonging to the given path
selected.Expand();
}
}
}
}

Finding the node is no problem. But it seems the method Expand() has no
effect :(

I hope someone can help.

Greetings

Karim

Nov 19 '05 #2
....no I don't think so. Problem is not to store and get the state of the
tree. Problem is that I cannot tell the Tree to expand a certain node.
This has to work even if the page is loaded for the first time. If I give a
path in the querystring the tree should expand this path.

Any other idea?
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> schrieb im
Newsbeitrag news:%2****************@TK2MSFTNGP09.phx.gbl...
Would this [1] help?
See also...
google: postbackurl site:msdn2.microsoft.com

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

[1] http://msdn2.microsoft.com/en-us/lib...us,vs.80).aspx

"Karim El Jed" <no****@netcreate.de> wrote in message
news:eH**************@TK2MSFTNGP10.phx.gbl...
Hi,

I'm trying to expand a special Node of my TreeView from Codebehind.
I have a TreeView on a page for navigating to another site. On the other
tsite here is the same TreeView more precisely a new TreeView with the
same nodes ;)
So I would like to keep the expanding state of the first Tree for the
second one on the next page. At least the last selected node (path will
be saved in query string) should be expanded.

Remarks: The TreeView is rendered in an IFrame to enable scrolling. Maybe
there might be another solution. Let me know if someone knows ;)

Here is what I tried:

protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{
//Populate the Tree
TreeView1.Nodes.Add(TopicFactory.PopulateTopicTree Nodes());
TreeView1.Target = "_parent";

if (Request.QueryString["path"] != null)
{
//path for the node is in the query string
string path = Request.QueryString["path"];
TreeNode selected = TreeView1.FindNode(path);

if (selected != null)
{
//expand the node belonging to the given path
selected.Expand();
}
}
}
}

Finding the node is no problem. But it seems the method Expand() has no
effect :(

I hope someone can help.

Greetings

Karim


Nov 19 '05 #3
Have you done something similar using treeview v.1.1
Patrick
"Karim El Jed" <no****@netcreate.de> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
...no I don't think so. Problem is not to store and get the state of the
tree. Problem is that I cannot tell the Tree to expand a certain node.
This has to work even if the page is loaded for the first time. If I give a path in the querystring the tree should expand this path.

Any other idea?
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> schrieb im
Newsbeitrag news:%2****************@TK2MSFTNGP09.phx.gbl...
Would this [1] help?
See also...
google: postbackurl site:msdn2.microsoft.com

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

[1] http://msdn2.microsoft.com/en-us/lib...us,vs.80).aspx

"Karim El Jed" <no****@netcreate.de> wrote in message
news:eH**************@TK2MSFTNGP10.phx.gbl...
Hi,

I'm trying to expand a special Node of my TreeView from Codebehind.
I have a TreeView on a page for navigating to another site. On the other tsite here is the same TreeView more precisely a new TreeView with the
same nodes ;)
So I would like to keep the expanding state of the first Tree for the
second one on the next page. At least the last selected node (path will
be saved in query string) should be expanded.

Remarks: The TreeView is rendered in an IFrame to enable scrolling. Maybe there might be another solution. Let me know if someone knows ;)

Here is what I tried:

protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{
//Populate the Tree
TreeView1.Nodes.Add(TopicFactory.PopulateTopicTree Nodes());
TreeView1.Target = "_parent";

if (Request.QueryString["path"] != null)
{
//path for the node is in the query string
string path = Request.QueryString["path"];
TreeNode selected = TreeView1.FindNode(path);

if (selected != null)
{
//expand the node belonging to the given path
selected.Expand();
}
}
}
}

Finding the node is no problem. But it seems the method Expand() has no
effect :(

I hope someone can help.

Greetings

Karim



Nov 19 '05 #4
No, I didn't. I thought Treeview 1.1 only runs in IE, doesn't it?
I also tried to expand the Treenode before I add it to the Treeview but this
didn't work either.

Karim

"Patirck Ige" <na********@hotmail.com> schrieb im Newsbeitrag
news:e6*************@TK2MSFTNGP10.phx.gbl...
Have you done something similar using treeview v.1.1
Patrick
"Karim El Jed" <no****@netcreate.de> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
...no I don't think so. Problem is not to store and get the state of the
tree. Problem is that I cannot tell the Tree to expand a certain node.
This has to work even if the page is loaded for the first time. If I give

a
path in the querystring the tree should expand this path.

Any other idea?
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> schrieb im
Newsbeitrag news:%2****************@TK2MSFTNGP09.phx.gbl...
> Would this [1] help?
> See also...
> google: postbackurl site:msdn2.microsoft.com
>
> <%= Clinton Gallagher
> METROmilwaukee (sm) "A Regional Information Service"
> NET csgallagher AT metromilwaukee.com
> URL http://metromilwaukee.com/
> URL http://clintongallagher.metromilwaukee.com/
>
> [1] http://msdn2.microsoft.com/en-us/lib...us,vs.80).aspx
>
>
>
> "Karim El Jed" <no****@netcreate.de> wrote in message
> news:eH**************@TK2MSFTNGP10.phx.gbl...
>> Hi,
>>
>> I'm trying to expand a special Node of my TreeView from Codebehind.
>> I have a TreeView on a page for navigating to another site. On the other >> tsite here is the same TreeView more precisely a new TreeView with the
>> same nodes ;)
>> So I would like to keep the expanding state of the first Tree for the
>> second one on the next page. At least the last selected node (path
>> will
>> be saved in query string) should be expanded.
>>
>> Remarks: The TreeView is rendered in an IFrame to enable scrolling. Maybe >> there might be another solution. Let me know if someone knows ;)
>>
>> Here is what I tried:
>>
>> protected void Page_Load(object sender, EventArgs e)
>> {
>>
>> if (!IsPostBack)
>> {
>> //Populate the Tree
>> TreeView1.Nodes.Add(TopicFactory.PopulateTopicTree Nodes());
>> TreeView1.Target = "_parent";
>>
>> if (Request.QueryString["path"] != null)
>> {
>> //path for the node is in the query string
>> string path = Request.QueryString["path"];
>> TreeNode selected = TreeView1.FindNode(path);
>>
>> if (selected != null)
>> {
>> //expand the node belonging to the given path
>> selected.Expand();
>> }
>> }
>> }
>> }
>>
>> Finding the node is no problem. But it seems the method Expand() has
>> no
>> effect :(
>>
>> I hope someone can help.
>>
>> Greetings
>>
>> Karim
>>
>
>



Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Olga | last post by:
How to fill treeview in ASP? Thanks
6
by: ricky | last post by:
i want to use treeview in ASP page but i m unable to populate it plz help me how to impliment treeview in asp
3
by: Sam | last post by:
Hi, I'd like to select a node in my code and expand that node. How can I do the selection ? How can I expand it once I've selected the node ? Thx
2
by: das | last post by:
hi all, i want to create dynamic treeview in asp.net 2.0& bind with sqlserver2005 table. the depth can beanynumber, so that the end user can create any number of child nodes & bind with ss2k5...
0
by: Anders | last post by:
Hi I have a singlepage design (non-frame) so the whole page is refreshe on postback. I have a treebiew filled from a site.map. Works fine. But on every postback every single node in the...
1
by: abdulbasith | last post by:
i need to display the files and folders of c:\ drive in treeview using asp.net in my application .can any one help me in it. thanks regards Abdul basith
0
by: ashokkumarsep02 | last post by:
hi , i have to create a static treeview in asp
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.