Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Viewstate and Collections

Reply
Thread Tools

Viewstate and Collections

 
 
mark
Guest
Posts: n/a
 
      01-07-2004
Hi there,

I've got a problem. I need to store my server controls view state.
This all seems very easy when dealing with simple properties, just pop
them in the Viewstate bag and retrieve them when you need them.

Problem for me is that I have a Server Control which is a form of
datagrid display and it looks like the following: -

My Server Control
- ColumnHeaders (collection)
- ColumnHeader (class)
- HeaderButtons (collection)
- Button (class)
- DetailButtons (collection)
- Button (class)
- Rows (collection)
- Row (collection)
- Item (class)
- ID (property
- Title (property)
- Datasource (method)
- Etc...

I've looked all over the net trying to find out how to save the
viewstate of all my collections but I haven't found anything that
helps. I've read about LoadViewState and SaveViewState and the
IStateManager and seen examples using them but I haven't seen any
examples that show the Container, Collection and Class.

I guess that my collection and classes need to implement the
IStateManger interface? Or is it just the collection?

Do I need to use TrackViewState?

I know these could be all very simple questions to answer, but they
aren't for me!

Please help! What would be really useful would be just a short example
in C# showing how it's done. I find that the best way to understand.

Thank you in advance,

Mark (in dire need) Bateman...
 
Reply With Quote
 
 
 
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      01-07-2004
hi mark,
To improve efficiency, or to save a custom type that cannot be stored by
default in ViewState, a control can customize how property data is stored in
ViewState. If a control customizes storage of property data, the control
must also provide a custom implementation for restoring property values from
data stored in ViewState. the base class Control provides two methods for
this purpose, SaveViewState and LoadViewState.
And yes, you need to use trackviewstate. The examples shows everything in
detail, give it a look :
http://msdn.microsoft.com/library/de...trolsample.asp


"mark" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) m...
> Hi there,
>
> I've got a problem. I need to store my server controls view state.
> This all seems very easy when dealing with simple properties, just pop
> them in the Viewstate bag and retrieve them when you need them.
>
> Problem for me is that I have a Server Control which is a form of
> datagrid display and it looks like the following: -
>
> My Server Control
> - ColumnHeaders (collection)
> - ColumnHeader (class)
> - HeaderButtons (collection)
> - Button (class)
> - DetailButtons (collection)
> - Button (class)
> - Rows (collection)
> - Row (collection)
> - Item (class)
> - ID (property
> - Title (property)
> - Datasource (method)
> - Etc...
>
> I've looked all over the net trying to find out how to save the
> viewstate of all my collections but I haven't found anything that
> helps. I've read about LoadViewState and SaveViewState and the
> IStateManager and seen examples using them but I haven't seen any
> examples that show the Container, Collection and Class.
>
> I guess that my collection and classes need to implement the
> IStateManger interface? Or is it just the collection?
>
> Do I need to use TrackViewState?
>
> I know these could be all very simple questions to answer, but they
> aren't for me!
>
> Please help! What would be really useful would be just a short example
> in C# showing how it's done. I find that the best way to understand.
>
> Thank you in advance,
>
> Mark (in dire need) Bateman...



 
Reply With Quote
 
 
 
 
Lostinet.Web Support
Guest
Posts: n/a
 
      01-07-2004
make your collection implement IStateManager

override TrackViewState,SaveViewState,LoadViewState as:

override protected void TrackViewState()
{
base.TrackViewState();
MyItems.TrackViewState();
}
override protected object SaveViewState()
{
return new Pair(base.SaveViewState(),MyItems.SaveViewState()) ;
}
override protected void LoadViewState(object state)
{
Pair p=(Pair)state;
if(p==null)return;
base.LoadViewState(p.First);
MyItems.SaveViewState(p.Second);
}

--
http://www.lostinet.com/
---------------------------
Lostinet.Web Controls&Components help you to build better Asp.Net
CustomerControl&UserControl&Application.
---------------------------
It's FREE !!
---------------------------
ControlHelper&HelperElement for MessageBox&Dialog
ComboBox,ComboCalendar,SmartIframe
---------------------------
Remote Asp.Net Execution

"mark" <(E-Mail Removed)> ????
news:(E-Mail Removed) m...
> Hi there,
>
> I've got a problem. I need to store my server controls view state.
> This all seems very easy when dealing with simple properties, just pop
> them in the Viewstate bag and retrieve them when you need them.
>
> Problem for me is that I have a Server Control which is a form of
> datagrid display and it looks like the following: -
>
> My Server Control
> - ColumnHeaders (collection)
> - ColumnHeader (class)
> - HeaderButtons (collection)
> - Button (class)
> - DetailButtons (collection)
> - Button (class)
> - Rows (collection)
> - Row (collection)
> - Item (class)
> - ID (property
> - Title (property)
> - Datasource (method)
> - Etc...
>
> I've looked all over the net trying to find out how to save the
> viewstate of all my collections but I haven't found anything that
> helps. I've read about LoadViewState and SaveViewState and the
> IStateManager and seen examples using them but I haven't seen any
> examples that show the Container, Collection and Class.
>
> I guess that my collection and classes need to implement the
> IStateManger interface? Or is it just the collection?
>
> Do I need to use TrackViewState?
>
> I know these could be all very simple questions to answer, but they
> aren't for me!
>
> Please help! What would be really useful would be just a short example
> in C# showing how it's done. I find that the best way to understand.
>
> Thank you in advance,
>
> Mark (in dire need) Bateman...



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with ViewState: "function 'ViewState.get_Item' evaluated and returned null" Steph ASP .Net 2 05-11-2011 02:35 PM
Maintaining viewstate in Collections Patrick Wilby via .NET 247 ASP .Net Web Controls 0 04-23-2004 04:57 AM
Corrupted ViewState (Yes, another issue concerning viewstate) Ben Rush ASP .Net 2 12-05-2003 04:17 PM
Sorting collections based on nested collections Doug Poland Java 9 09-27-2003 10:46 PM
InnerProperty Persistance for Collections containing other Collections mutex ASP .Net Building Controls 0 07-27-2003 02:45 PM



Advertisments