473,324 Members | 2,257 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,324 software developers and data experts.

Maintain Tree View State

I have a treeview control that I use as a menu & navigation control within a
master page. The nodes for this control are loaded from a database which
contains the text and url of each like and the hierarchy of the menu tree.
All pretty normal stuff.

Is there any simple method of maintaining the expanded / collapsed state of
each node as my application moves from page to page? Remember this is on a
master page used by numerous content pages.

I am looking for something obvious that I might be missing.

I do have two solutions that are coded and work but wondering if there is
something better?

1. Clone the entire control and put it in Session or Cache.
2. Build a Dictionary based on the path at each node and the state of each
node. Put the dictionary in Session or Cache.

Thanks,
Jan 11 '06 #1
7 10320
Andrew,

I would make a simple array of which node numbers are expanded and assume
all others are collapsed and store that list in viewstate (an arraylist
would work nicely). Then you can have the master page store fill out and
store to viewstate the arraylist and retrieve it each time the master page
loads the tree again.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Andrew Robinson" <ne****@nospam.nospam> wrote in message
news:OF*************@TK2MSFTNGP12.phx.gbl...
I have a treeview control that I use as a menu & navigation control within
a master page. The nodes for this control are loaded from a database which
contains the text and url of each like and the hierarchy of the menu tree.
All pretty normal stuff.

Is there any simple method of maintaining the expanded / collapsed state
of each node as my application moves from page to page? Remember this is
on a master page used by numerous content pages.

I am looking for something obvious that I might be missing.

I do have two solutions that are coded and work but wondering if there is
something better?

1. Clone the entire control and put it in Session or Cache.
2. Build a Dictionary based on the path at each node and the state of each
node. Put the dictionary in Session or Cache.

Thanks,

Jan 11 '06 #2
Justin,

Thanks. Basically number 2 that I listed.
"S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:OD**************@TK2MSFTNGP10.phx.gbl...
Andrew,

I would make a simple array of which node numbers are expanded and assume
all others are collapsed and store that list in viewstate (an arraylist
would work nicely). Then you can have the master page store fill out and
store to viewstate the arraylist and retrieve it each time the master page
loads the tree again.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Andrew Robinson" <ne****@nospam.nospam> wrote in message
news:OF*************@TK2MSFTNGP12.phx.gbl...
I have a treeview control that I use as a menu & navigation control within
a master page. The nodes for this control are loaded from a database which
contains the text and url of each like and the hierarchy of the menu tree.
All pretty normal stuff.

Is there any simple method of maintaining the expanded / collapsed state
of each node as my application moves from page to page? Remember this is
on a master page used by numerous content pages.

I am looking for something obvious that I might be missing.

I do have two solutions that are coded and work but wondering if there is
something better?

1. Clone the entire control and put it in Session or Cache.
2. Build a Dictionary based on the path at each node and the state of
each node. Put the dictionary in Session or Cache.

Thanks,


Jan 11 '06 #3
Yep. :) But I wanted to make certain that you saw viewstate as an option. I
like to store some things client side when I can. As long as it isn't a
great deal of information it is still just as fast for the customer and it
keeps the server as lean as possible.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Andrew Robinson" <ne****@nospam.nospam> wrote in message
news:u4**************@TK2MSFTNGP09.phx.gbl...
Justin,

Thanks. Basically number 2 that I listed.
"S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote
in message news:OD**************@TK2MSFTNGP10.phx.gbl...
Andrew,

I would make a simple array of which node numbers are expanded and assume
all others are collapsed and store that list in viewstate (an arraylist
would work nicely). Then you can have the master page store fill out and
store to viewstate the arraylist and retrieve it each time the master
page loads the tree again.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Andrew Robinson" <ne****@nospam.nospam> wrote in message
news:OF*************@TK2MSFTNGP12.phx.gbl...
I have a treeview control that I use as a menu & navigation control
within a master page. The nodes for this control are loaded from a
database which contains the text and url of each like and the hierarchy
of the menu tree. All pretty normal stuff.

Is there any simple method of maintaining the expanded / collapsed state
of each node as my application moves from page to page? Remember this is
on a master page used by numerous content pages.

I am looking for something obvious that I might be missing.

I do have two solutions that are coded and work but wondering if there
is something better?

1. Clone the entire control and put it in Session or Cache.
2. Build a Dictionary based on the path at each node and the state of
each node. Put the dictionary in Session or Cache.

Thanks,



Jan 11 '06 #4
Justin,

I am back to my original solution on this one.

1. ViewState is not maintained between two different pages. You need to save
you state in either Session or the Server Cache. Remember that I am using
this within a Master Page that is used on multiple content pages.

2. Is there some type of Node ID or number that can be used as a key for
each node? I am currently recursively walking the node tree and just using
an index that is external to the nodes that I add to. I don't think that you
can use the Data or Value path because there is no guarantee that it will
generate a unique key.

Thanks,

-Andrew

"S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:%2*****************@TK2MSFTNGP12.phx.gbl...
Yep. :) But I wanted to make certain that you saw viewstate as an option.
I like to store some things client side when I can. As long as it isn't a
great deal of information it is still just as fast for the customer and it
keeps the server as lean as possible.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Andrew Robinson" <ne****@nospam.nospam> wrote in message
news:u4**************@TK2MSFTNGP09.phx.gbl...
Justin,

Thanks. Basically number 2 that I listed.
"S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote
in message news:OD**************@TK2MSFTNGP10.phx.gbl...
Andrew,

I would make a simple array of which node numbers are expanded and
assume all others are collapsed and store that list in viewstate (an
arraylist would work nicely). Then you can have the master page store
fill out and store to viewstate the arraylist and retrieve it each time
the master page loads the tree again.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Andrew Robinson" <ne****@nospam.nospam> wrote in message
news:OF*************@TK2MSFTNGP12.phx.gbl...
I have a treeview control that I use as a menu & navigation control
within a master page. The nodes for this control are loaded from a
database which contains the text and url of each like and the hierarchy
of the menu tree. All pretty normal stuff.

Is there any simple method of maintaining the expanded / collapsed
state of each node as my application moves from page to page? Remember
this is on a master page used by numerous content pages.

I am looking for something obvious that I might be missing.

I do have two solutions that are coded and work but wondering if there
is something better?

1. Clone the entire control and put it in Session or Cache.
2. Build a Dictionary based on the path at each node and the state of
each node. Put the dictionary in Session or Cache.

Thanks,



Jan 12 '06 #5
Andrew,

You can expose objects on the master page to the content pages. Just declare
them as Friend. But you'll certainly have an easier time using session
because you would then have to code a base content page and inherit it so
that the code to store the tree in viewstate doesn't have to be repeated on
each and every page.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Andrew Robinson" <ne****@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Justin,

I am back to my original solution on this one.

1. ViewState is not maintained between two different pages. You need to
save you state in either Session or the Server Cache. Remember that I am
using this within a Master Page that is used on multiple content pages.

2. Is there some type of Node ID or number that can be used as a key for
each node? I am currently recursively walking the node tree and just using
an index that is external to the nodes that I add to. I don't think that
you can use the Data or Value path because there is no guarantee that it
will generate a unique key.

Thanks,

-Andrew

"S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote
in message news:%2*****************@TK2MSFTNGP12.phx.gbl...
Yep. :) But I wanted to make certain that you saw viewstate as an option.
I like to store some things client side when I can. As long as it isn't a
great deal of information it is still just as fast for the customer and
it keeps the server as lean as possible.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Andrew Robinson" <ne****@nospam.nospam> wrote in message
news:u4**************@TK2MSFTNGP09.phx.gbl...
Justin,

Thanks. Basically number 2 that I listed.
"S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com>
wrote in message news:OD**************@TK2MSFTNGP10.phx.gbl...
Andrew,

I would make a simple array of which node numbers are expanded and
assume all others are collapsed and store that list in viewstate (an
arraylist would work nicely). Then you can have the master page store
fill out and store to viewstate the arraylist and retrieve it each time
the master page loads the tree again.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Andrew Robinson" <ne****@nospam.nospam> wrote in message
news:OF*************@TK2MSFTNGP12.phx.gbl...
>I have a treeview control that I use as a menu & navigation control
>within a master page. The nodes for this control are loaded from a
>database which contains the text and url of each like and the hierarchy
>of the menu tree. All pretty normal stuff.
>
> Is there any simple method of maintaining the expanded / collapsed
> state of each node as my application moves from page to page? Remember
> this is on a master page used by numerous content pages.
>
> I am looking for something obvious that I might be missing.
>
> I do have two solutions that are coded and work but wondering if there
> is something better?
>
> 1. Clone the entire control and put it in Session or Cache.
> 2. Build a Dictionary based on the path at each node and the state of
> each node. Put the dictionary in Session or Cache.
>
> Thanks,
>
>



Jan 12 '06 #6
Hi Justin,

For your #2 question, I think you can consider idenitfy TreeView's Nodes
through NodePath, you can find that TreeView control itself has the
FindNode method which used a certain TreeNode path to find a TreeNode...
This can help you storing Node info in Session or other global wide
storage...

#TreeView.FindNode
http://msdn2.microsoft.com/en-us/lib...trols.treeview.
findnode.aspx

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "Andrew Robinson" <ne****@nospam.nospam>
| References: <OF*************@TK2MSFTNGP12.phx.gbl>
<OD**************@TK2MSFTNGP10.phx.gbl>
<u4**************@TK2MSFTNGP09.phx.gbl>
<#1*************@TK2MSFTNGP12.phx.gbl>
| Subject: Re: Maintain Tree View State
| Date: Thu, 12 Jan 2006 09:07:13 -0800
| Lines: 95
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| X-RFC2646: Format=Flowed; Response
| Message-ID: <#d**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 216.57.203.121
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:370383
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Justin,
|
| I am back to my original solution on this one.
|
| 1. ViewState is not maintained between two different pages. You need to
save
| you state in either Session or the Server Cache. Remember that I am using
| this within a Master Page that is used on multiple content pages.
|
| 2. Is there some type of Node ID or number that can be used as a key for
| each node? I am currently recursively walking the node tree and just
using
| an index that is external to the nodes that I add to. I don't think that
you
| can use the Data or Value path because there is no guarantee that it will
| generate a unique key.
|
| Thanks,
|
| -Andrew
|
|
|
| "S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote
in
| message news:%2*****************@TK2MSFTNGP12.phx.gbl...
| > Yep. :) But I wanted to make certain that you saw viewstate as an
option.
| > I like to store some things client side when I can. As long as it isn't
a
| > great deal of information it is still just as fast for the customer and
it
| > keeps the server as lean as possible.
| >
| > --
| > Sincerely,
| >
| > S. Justin Gengo, MCP
| > Web Developer / Programmer
| >
| > www.aboutfortunate.com
| >
| > "Out of chaos comes order."
| > Nietzsche
| > "Andrew Robinson" <ne****@nospam.nospam> wrote in message
| > news:u4**************@TK2MSFTNGP09.phx.gbl...
| >> Justin,
| >>
| >> Thanks. Basically number 2 that I listed.
| >>
| >>
| >> "S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com>
wrote
| >> in message news:OD**************@TK2MSFTNGP10.phx.gbl...
| >>> Andrew,
| >>>
| >>> I would make a simple array of which node numbers are expanded and
| >>> assume all others are collapsed and store that list in viewstate (an
| >>> arraylist would work nicely). Then you can have the master page store
| >>> fill out and store to viewstate the arraylist and retrieve it each
time
| >>> the master page loads the tree again.
| >>>
| >>> --
| >>> Sincerely,
| >>>
| >>> S. Justin Gengo, MCP
| >>> Web Developer / Programmer
| >>>
| >>> www.aboutfortunate.com
| >>>
| >>> "Out of chaos comes order."
| >>> Nietzsche
| >>> "Andrew Robinson" <ne****@nospam.nospam> wrote in message
| >>> news:OF*************@TK2MSFTNGP12.phx.gbl...
| >>>>I have a treeview control that I use as a menu & navigation control
| >>>>within a master page. The nodes for this control are loaded from a
| >>>>database which contains the text and url of each like and the
hierarchy
| >>>>of the menu tree. All pretty normal stuff.
| >>>>
| >>>> Is there any simple method of maintaining the expanded / collapsed
| >>>> state of each node as my application moves from page to page?
Remember
| >>>> this is on a master page used by numerous content pages.
| >>>>
| >>>> I am looking for something obvious that I might be missing.
| >>>>
| >>>> I do have two solutions that are coded and work but wondering if
there
| >>>> is something better?
| >>>>
| >>>> 1. Clone the entire control and put it in Session or Cache.
| >>>> 2. Build a Dictionary based on the path at each node and the state
of
| >>>> each node. Put the dictionary in Session or Cache.
| >>>>
| >>>> Thanks,
| >>>>
| >>>>
| >>>
| >>>
| >>
| >>
| >
| >
|
|
|

Jan 13 '06 #7
I find it hard to believe that Microsoft has not provided an easier way to do this! It renders the TreeView control virtually useless as a menu if one cannot maintain state across page loads. Are we certain there isn't an easier way to do this?

If not, could you post the code you are using?

Thanks!
Apr 28 '06 #8

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

Similar topics

3
by: | last post by:
This is a very open ended question. I have an app with a page that uses link buttons to change the display. On the prior page you have a list of objects. You click one of those objects to see it's...
0
by: Tree menu using XML | last post by:
I have one XML file that has nodes and sub node and each and every node has the attribute call visible if its value is true then diplay this node else don't display thid node, but this condition i...
5
by: Dominic | last post by:
My question is about how to maintain view state in mobile ASP.NET across postback / request in a web farm environment. First of all, let's assume the web-farm does NOT use stick-session feature....
1
by: David A. Osborn | last post by:
Is there a way to maintain the highlight of an item in a tree view control? Currently if I select another control on the screen then the item on the tree view loses its highlight. I want to...
2
by: Varangian | last post by:
Hi there again... is there a way to maintain the ViewState of WebControls when using AJAX or Callbacks ? Every time I refresh a page or use a postback from a control it would loose the...
0
by: nimisha | last post by:
I have been trying to learn how to do a c++ tic tac toe game, with first implementing the game tree in a function and then having the AI in another function which uses minimax algorithm. I came...
1
by: zwieback89 | last post by:
Hi, I have a org tree with hierarchical display of employees built using classic asp and vbscript. I also have list of radio buttons for report names. I have 1 select box with dates in it....
2
by: Steve Richter | last post by:
I would like store and recall user settings and window state for each user of my application. By state I mean recalling at application start the location in a list view the app was at the last...
0
by: Homer J. Simpson | last post by:
A few weeks ago I asked for suggestions on how to persist a tree's node state to cookies, without causing postbacks on each click in the tree. I had a single .aspx file, with a row of buttons on...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.