472,985 Members | 2,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,985 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 10091
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
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.