By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,435 Members | 2,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,435 IT Pros & Developers. It's quick & easy.

Expand TreeView programmatically (ASP.NET 2.0)

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
....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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.