Showing posts with label session. Show all posts
Showing posts with label session. Show all posts

Thursday, March 29, 2012

Separating form elements on aspx page

I have a series of controls (a few buttons that clears content,
inserts data into dbase, logs out a user session) that need to work
independently of each other, but I cannot put all these controls into
more than one form tag, as asp.net pages are not allowed to have more
than one < form runat: server> tag. . If i try to logout of a session
on the page with this:
'''
<script language="VB" runat="server">
Sub logout(Sender As Object, e As EventArgs)
Session.Clear()
Response.Redirect("admin-login.aspx")
End Sub
</script>
<asp:Button id="button4" onClick="logout" Text="Logout"
class="inputSubmit" runat="server" />
'''

...it tries to post my info again from the insert textbox objects
before the logout button.

??
chumleyiframes?

Eliyahu

"Chumley the Walrus" <springb2k@.yahoo.com> wrote in message
news:1ef65641.0408030802.1c912932@.posting.google.c om...
> I have a series of controls (a few buttons that clears content,
> inserts data into dbase, logs out a user session) that need to work
> independently of each other, but I cannot put all these controls into
> more than one form tag, as asp.net pages are not allowed to have more
> than one < form runat: server> tag. . If i try to logout of a session
> on the page with this:
> '''
> <script language="VB" runat="server">
> Sub logout(Sender As Object, e As EventArgs)
> Session.Clear()
> Response.Redirect("admin-login.aspx")
> End Sub
> </script>
> <asp:Button id="button4" onClick="logout" Text="Logout"
> class="inputSubmit" runat="server" />
> '''
> ..it tries to post my info again from the insert textbox objects
> before the logout button.
> ??
> chumley

Separating form elements on aspx page

I have a series of controls (a few buttons that clears content,
inserts data into dbase, logs out a user session) that need to work
independently of each other, but I cannot put all these controls into
more than one form tag, as asp.net pages are not allowed to have more
than one < form runat: server> tag. . If i try to logout of a session
on the page with this:
'''
<script language="VB" runat="server">
Sub logout(Sender As Object, e As EventArgs)
Session.Clear()
Response.Redirect("admin-login.aspx")
End Sub
</script>
<asp:Button id="button4" onClick="logout" Text="Logout"
class="inputSubmit" runat="server" />
'''
..it tries to post my info again from the insert textbox objects
before the logout button.
'
chumleyiframes?
Eliyahu
"Chumley the Walrus" <springb2k@.yahoo.com> wrote in message
news:1ef65641.0408030802.1c912932@.posting.google.com...
> I have a series of controls (a few buttons that clears content,
> inserts data into dbase, logs out a user session) that need to work
> independently of each other, but I cannot put all these controls into
> more than one form tag, as asp.net pages are not allowed to have more
> than one < form runat: server> tag. . If i try to logout of a session
> on the page with this:
> '''
> <script language="VB" runat="server">
> Sub logout(Sender As Object, e As EventArgs)
> Session.Clear()
> Response.Redirect("admin-login.aspx")
> End Sub
> </script>
> <asp:Button id="button4" onClick="logout" Text="Logout"
> class="inputSubmit" runat="server" />
> '''
> ..it tries to post my info again from the insert textbox objects
> before the logout button.
> '
> chumley

Monday, March 26, 2012

serializable class

Hi,

How do you make a class generated by the DataSet.xsd serializable? So I can store it in session with SQL Server?

Thanks.

You can mark the class as serilizable like this:

[Serializable]
public class MyClass

{

//Class code...

}


Thanks. But the class I am trying to Serialized is generated by DataSet.xsd, so I cannot do that.

I have tried to make a partial class but it does not work:

[Serializable]

public partial class DataSetXSDClassName {

}


OH! Sorry... I missed the part of the xsd... Can you post the class generated by it then?


I am not sure about that but you can do the followin work around.

Provided your generated class look like this:

public class A{public int id;public string titlepublic A(int aId,string aTitle) { id = aId; title = aTitle; }}//then you define class B like this:[Serializable]public class B{public int id;public string title;public B(A obj) { id = obj.id; title = obj.title; }}
after that you can serialize and deserialize instances of B class and then use their members/properties to create A object and further use it in your code. Other benefit of it is that you can serialize only the information that you need.


The class is not actually 'physical' that I can go and copy and paste the code, but if any error occur then it will show up in debug mode, but will a weird filename like like random string.

Also the 'work around' class does work, but that will generated a class 99% the same as the one from xsd file. Any changes in dataset.xsd means I manually have to do the same for this 'work around' class.

But thanks for the comment.

Serializable Flag on a Class

My company has developed a backend component which needs to be carried
around in session state, therefore it must be marked [Serializable] at
the class level.
The problem I have with this is that now any class that this class uses
must also be marked as serializable. This is a huge pain since now we
have a dozen classes marked.
Can someone better explain why we have to chain mark the supporting
classes in the first place? Also, does marking all these classes have
some sort of negative impact?
My idea to get around this was to make one light-weight class (that had
no supporting classes) and then have some sort of factory populate it,
this would therefore only require us to mark it serializable and it
would be our traveling container.
Your feedback on this would be appreciated.Yes its a bit of a pain to do it that way if you have a large object
structure.
An alternative is to use the ISerializable interface.
Here's more info:
http://msdn.microsoft.com/library/d.../>
asstopic.asp
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"MrFile" <mrfile.email@.gmail.com> wrote in message
news:1150404557.306716.162240@.y41g2000cwy.googlegroups.com...
> My company has developed a backend component which needs to be carried
> around in session state, therefore it must be marked [Serializable] at
> the class level.
> The problem I have with this is that now any class that this class uses
> must also be marked as serializable. This is a huge pain since now we
> have a dozen classes marked.
> Can someone better explain why we have to chain mark the supporting
> classes in the first place? Also, does marking all these classes have
> some sort of negative impact?
> My idea to get around this was to make one light-weight class (that had
> no supporting classes) and then have some sort of factory populate it,
> this would therefore only require us to mark it serializable and it
> would be our traveling container.
> Your feedback on this would be appreciated.
>

Serializable Flag on a Class

My company has developed a backend component which needs to be carried
around in session state, therefore it must be marked [Serializable] at
the class level.

The problem I have with this is that now any class that this class uses
must also be marked as serializable. This is a huge pain since now we
have a dozen classes marked.

Can someone better explain why we have to chain mark the supporting
classes in the first place? Also, does marking all these classes have
some sort of negative impact?

My idea to get around this was to make one light-weight class (that had
no supporting classes) and then have some sort of factory populate it,
this would therefore only require us to mark it serializable and it
would be our traveling container.

Your feedback on this would be appreciated.Yes its a bit of a pain to do it that way if you have a large object
structure.
An alternative is to use the ISerializable interface.
Here's more info:
http://msdn.microsoft.com/library/d...lasst opic.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"MrFile" <mrfile.email@.gmail.com> wrote in message
news:1150404557.306716.162240@.y41g2000cwy.googlegr oups.com...
> My company has developed a backend component which needs to be carried
> around in session state, therefore it must be marked [Serializable] at
> the class level.
> The problem I have with this is that now any class that this class uses
> must also be marked as serializable. This is a huge pain since now we
> have a dozen classes marked.
> Can someone better explain why we have to chain mark the supporting
> classes in the first place? Also, does marking all these classes have
> some sort of negative impact?
> My idea to get around this was to make one light-weight class (that had
> no supporting classes) and then have some sort of factory populate it,
> this would therefore only require us to mark it serializable and it
> would be our traveling container.
> Your feedback on this would be appreciated.

serialization and Session Object

Hello,
I recently read that a class must support serialization in order for it to
be stored in the Session State. Before reading this I had been storing a
class to the Session State no problem (without serialization). The class is
simply a storage class and contains only primitive types...is it necessary
to serialize this object? If so, how do you go about serializing an entire
class?
Thanks much.BTW, using C#. Thanks
"Bilbo" <Bilbo@.cox.net> wrote in message
news:eZDMiA1aEHA.2516@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I recently read that a class must support serialization in order for it to
> be stored in the Session State. Before reading this I had been storing a
> class to the Session State no problem (without serialization). The class
is
> simply a storage class and contains only primitive types...is it
necessary
> to serialize this object? If so, how do you go about serializing an entire
> class?
> Thanks much.
>
It only needs to be serializable if you using session state other then
InProc. If you are using InProc, you can place anything you want into
session.
"Bilbo" <Bilbo@.cox.net> wrote in message
news:eZDMiA1aEHA.2516@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I recently read that a class must support serialization in order for it to
> be stored in the Session State. Before reading this I had been storing a
> class to the Session State no problem (without serialization). The class
is
> simply a storage class and contains only primitive types...is it
necessary
> to serialize this object? If so, how do you go about serializing an entire
> class?
> Thanks much.
>
"Bilbo" <Bilbo@.cox.net> wrote in news:eZDMiA1aEHA.2516
@.TK2MSFTNGP10.phx.gbl:

> is it necessary
> to serialize this object?
I think only if you're using session variables in a webfarm:
http://support.microsoft.com/defaul...b;EN-US;q312112
I never had problems storing complex objects in a sesion variable on a
single web server environment.
Lucas Tam (REMOVEnntp@.rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
[url]http://members.ebay.com/aboutme/spot18/[/url]
Check in your Web.config, that's where it is set. InProc is the default.
And if you haven't had any serialization warnings after putting custom
objects into session, then you're using InProc.
"Bilbo" <Bilbo@.cox.net> wrote in message
news:e$8bUo1aEHA.596@.TK2MSFTNGP11.phx.gbl...
> Thanks for your response. How can I tell if I am using InProc?
> Thanks.
>
> "Marina" <someone@.nospam.com> wrote in message
> news:O3%23RuF1aEHA.3820@.tk2msftngp13.phx.gbl...
it
> to
a
class
> entire
>
Thanks for your response. How can I tell if I am using InProc?
Thanks.
"Marina" <someone@.nospam.com> wrote in message
news:O3%23RuF1aEHA.3820@.tk2msftngp13.phx.gbl...
> It only needs to be serializable if you using session state other then
> InProc. If you are using InProc, you can place anything you want into
> session.
> "Bilbo" <Bilbo@.cox.net> wrote in message
> news:eZDMiA1aEHA.2516@.TK2MSFTNGP10.phx.gbl...
to
> is
> necessary
entire
>

Saturday, March 24, 2012

serialization and Session Object

Hello,

I recently read that a class must support serialization in order for it to
be stored in the Session State. Before reading this I had been storing a
class to the Session State no problem (without serialization). The class is
simply a storage class and contains only primitive types...is it necessary
to serialize this object? If so, how do you go about serializing an entire
class?

Thanks much.BTW, using C#. Thanks

"Bilbo" <Bilbo@.cox.net> wrote in message
news:eZDMiA1aEHA.2516@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I recently read that a class must support serialization in order for it to
> be stored in the Session State. Before reading this I had been storing a
> class to the Session State no problem (without serialization). The class
is
> simply a storage class and contains only primitive types...is it
necessary
> to serialize this object? If so, how do you go about serializing an entire
> class?
> Thanks much.
"Bilbo" <Bilbo@.cox.net> wrote in news:eZDMiA1aEHA.2516
@.TK2MSFTNGP10.phx.gbl:

> is it necessary
> to serialize this object?

I think only if you're using session variables in a webfarm:

http://support.microsoft.com/defaul...b;EN-US;q312112

I never had problems storing complex objects in a sesion variable on a
single web server environment.

--
Lucas Tam (REMOVEnntp@.rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
It only needs to be serializable if you using session state other then
InProc. If you are using InProc, you can place anything you want into
session.

"Bilbo" <Bilbo@.cox.net> wrote in message
news:eZDMiA1aEHA.2516@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I recently read that a class must support serialization in order for it to
> be stored in the Session State. Before reading this I had been storing a
> class to the Session State no problem (without serialization). The class
is
> simply a storage class and contains only primitive types...is it
necessary
> to serialize this object? If so, how do you go about serializing an entire
> class?
> Thanks much.
Thanks for your response. How can I tell if I am using InProc?

Thanks.

"Marina" <someone@.nospam.com> wrote in message
news:O3%23RuF1aEHA.3820@.tk2msftngp13.phx.gbl...
> It only needs to be serializable if you using session state other then
> InProc. If you are using InProc, you can place anything you want into
> session.
> "Bilbo" <Bilbo@.cox.net> wrote in message
> news:eZDMiA1aEHA.2516@.TK2MSFTNGP10.phx.gbl...
> > Hello,
> > I recently read that a class must support serialization in order for it
to
> > be stored in the Session State. Before reading this I had been storing a
> > class to the Session State no problem (without serialization). The class
> is
> > simply a storage class and contains only primitive types...is it
> necessary
> > to serialize this object? If so, how do you go about serializing an
entire
> > class?
> > Thanks much.
Check in your Web.config, that's where it is set. InProc is the default.

And if you haven't had any serialization warnings after putting custom
objects into session, then you're using InProc.

"Bilbo" <Bilbo@.cox.net> wrote in message
news:e$8bUo1aEHA.596@.TK2MSFTNGP11.phx.gbl...
> Thanks for your response. How can I tell if I am using InProc?
> Thanks.
>
> "Marina" <someone@.nospam.com> wrote in message
> news:O3%23RuF1aEHA.3820@.tk2msftngp13.phx.gbl...
> > It only needs to be serializable if you using session state other then
> > InProc. If you are using InProc, you can place anything you want into
> > session.
> > "Bilbo" <Bilbo@.cox.net> wrote in message
> > news:eZDMiA1aEHA.2516@.TK2MSFTNGP10.phx.gbl...
> > > Hello,
> > > > I recently read that a class must support serialization in order for
it
> to
> > > be stored in the Session State. Before reading this I had been storing
a
> > > class to the Session State no problem (without serialization). The
class
> > is
> > > simply a storage class and contains only primitive types...is it
> > necessary
> > > to serialize this object? If so, how do you go about serializing an
> entire
> > > class?
> > > > Thanks much.
> >

Serialization of Session objects

Hello,
I have implemented SQL Server session state in my application however I am
having some problems. Simple objects stored in Session state are fine and ar
e
handled by .NET, however when I try to store more complex objects such as an
ArrayList in session state I am not able to figure out exactly what I have t
o
do to serialize and deserialize the object.
There doesn't seem to be any code examples around when it comes to
serializing session objects. Could anyone provide me with some code that
would help?
I have managed to successfully serialize and deserialize an object to a file
but I am specifically looking to serialize the object to session state.
Thanks,
GaryAny class stored in session must implement the ISerializable attribute.
http://msdn.microsoft.com/library/d.../>
asstopic.asp
Robbe Morris - 2004/2005 Microsoft MVP C#
Earn money answering .NET Framework
messageboard posts at EggHeadCafe.com.
http://www.eggheadcafe.com/forums/merit.asp
"Gary" <Gary@.discussions.microsoft.com> wrote in message
news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
> Hello,
> I have implemented SQL Server session state in my application however I am
> having some problems. Simple objects stored in Session state are fine and
> are
> handled by .NET, however when I try to store more complex objects such as
> an
> ArrayList in session state I am not able to figure out exactly what I have
> to
> do to serialize and deserialize the object.
> There doesn't seem to be any code examples around when it comes to
> serializing session objects. Could anyone provide me with some code that
> would help?
> I have managed to successfully serialize and deserialize an object to a
> file
> but I am specifically looking to serialize the object to session state.
> Thanks,
> Gary
Gary,
All you have to do is to put a line
[Serializable]
before definition of every class you are going to save in the session state.
Eliyahu
"Gary" <Gary@.discussions.microsoft.com> wrote in message
news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
> Hello,
> I have implemented SQL Server session state in my application however I am
> having some problems. Simple objects stored in Session state are fine and
are
> handled by .NET, however when I try to store more complex objects such as
an
> ArrayList in session state I am not able to figure out exactly what I have
to
> do to serialize and deserialize the object.
> There doesn't seem to be any code examples around when it comes to
> serializing session objects. Could anyone provide me with some code that
> would help?
> I have managed to successfully serialize and deserialize an object to a
file
> but I am specifically looking to serialize the object to session state.
> Thanks,
> Gary
Hello,
Thank you very much for your reply, adding the <Serializable()> attribute to
my class has resolved my problem. I actually thought that you had to manuall
y
serialize the object and then put it in to the session object, I had no idea
that .NET handles this for you as long as the serialization attribute is
added. I have spent the best part of my day trying to figure this out so
thanks very much!
Regards,
Gary
"Eliyahu Goldin" wrote:

> Gary,
> All you have to do is to put a line
> [Serializable]
> before definition of every class you are going to save in the session stat
e.
>
> Eliyahu
> "Gary" <Gary@.discussions.microsoft.com> wrote in message
> news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
> are
> an
> to
> file
>
>
Hello,
Thank you very much for your reply, adding the <Serializable()> attribute to
my class has resolved my problem. I actually thought that you had to manuall
y
serialize the object and then put it in to the session object, I had no idea
that .NET handles this for you as long as the serialization attribute is
added. I have spent the best part of my day trying to figure this out so
thanks very much!
Regards,
Gary
"Robbe Morris [C# MVP]" wrote:

> Any class stored in session must implement the ISerializable attribute.
> http://msdn.microsoft.com/library/d...
classtopic.asp
> --
> Robbe Morris - 2004/2005 Microsoft MVP C#
> Earn money answering .NET Framework
> messageboard posts at EggHeadCafe.com.
> http://www.eggheadcafe.com/forums/merit.asp
>
> "Gary" <Gary@.discussions.microsoft.com> wrote in message
> news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
>
>

Serialization of Session objects

Hello,

I have implemented SQL Server session state in my application however I am
having some problems. Simple objects stored in Session state are fine and are
handled by .NET, however when I try to store more complex objects such as an
ArrayList in session state I am not able to figure out exactly what I have to
do to serialize and deserialize the object.

There doesn't seem to be any code examples around when it comes to
serializing session objects. Could anyone provide me with some code that
would help?

I have managed to successfully serialize and deserialize an object to a file
but I am specifically looking to serialize the object to session state.

Thanks,

GaryAny class stored in session must implement the ISerializable attribute.

http://msdn.microsoft.com/library/d...lasst opic.asp

--
Robbe Morris - 2004/2005 Microsoft MVP C#

Earn money answering .NET Framework
messageboard posts at EggHeadCafe.com.
http://www.eggheadcafe.com/forums/merit.asp

"Gary" <Gary@.discussions.microsoft.com> wrote in message
news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
> Hello,
> I have implemented SQL Server session state in my application however I am
> having some problems. Simple objects stored in Session state are fine and
> are
> handled by .NET, however when I try to store more complex objects such as
> an
> ArrayList in session state I am not able to figure out exactly what I have
> to
> do to serialize and deserialize the object.
> There doesn't seem to be any code examples around when it comes to
> serializing session objects. Could anyone provide me with some code that
> would help?
> I have managed to successfully serialize and deserialize an object to a
> file
> but I am specifically looking to serialize the object to session state.
> Thanks,
> Gary
Gary,

All you have to do is to put a line
[Serializable]

before definition of every class you are going to save in the session state.

Eliyahu

"Gary" <Gary@.discussions.microsoft.com> wrote in message
news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
> Hello,
> I have implemented SQL Server session state in my application however I am
> having some problems. Simple objects stored in Session state are fine and
are
> handled by .NET, however when I try to store more complex objects such as
an
> ArrayList in session state I am not able to figure out exactly what I have
to
> do to serialize and deserialize the object.
> There doesn't seem to be any code examples around when it comes to
> serializing session objects. Could anyone provide me with some code that
> would help?
> I have managed to successfully serialize and deserialize an object to a
file
> but I am specifically looking to serialize the object to session state.
> Thanks,
> Gary
Hello,

Thank you very much for your reply, adding the <Serializable()> attribute to
my class has resolved my problem. I actually thought that you had to manually
serialize the object and then put it in to the session object, I had no idea
that .NET handles this for you as long as the serialization attribute is
added. I have spent the best part of my day trying to figure this out so
thanks very much!

Regards,

Gary

"Eliyahu Goldin" wrote:

> Gary,
> All you have to do is to put a line
> [Serializable]
> before definition of every class you are going to save in the session state.
>
> Eliyahu
> "Gary" <Gary@.discussions.microsoft.com> wrote in message
> news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
> > Hello,
> > I have implemented SQL Server session state in my application however I am
> > having some problems. Simple objects stored in Session state are fine and
> are
> > handled by .NET, however when I try to store more complex objects such as
> an
> > ArrayList in session state I am not able to figure out exactly what I have
> to
> > do to serialize and deserialize the object.
> > There doesn't seem to be any code examples around when it comes to
> > serializing session objects. Could anyone provide me with some code that
> > would help?
> > I have managed to successfully serialize and deserialize an object to a
> file
> > but I am specifically looking to serialize the object to session state.
> > Thanks,
> > Gary
>
Hello,

Thank you very much for your reply, adding the <Serializable()> attribute to
my class has resolved my problem. I actually thought that you had to manually
serialize the object and then put it in to the session object, I had no idea
that .NET handles this for you as long as the serialization attribute is
added. I have spent the best part of my day trying to figure this out so
thanks very much!

Regards,

Gary

"Robbe Morris [C# MVP]" wrote:

> Any class stored in session must implement the ISerializable attribute.
> http://msdn.microsoft.com/library/d...lasst opic.asp
> --
> Robbe Morris - 2004/2005 Microsoft MVP C#
> Earn money answering .NET Framework
> messageboard posts at EggHeadCafe.com.
> http://www.eggheadcafe.com/forums/merit.asp
>
> "Gary" <Gary@.discussions.microsoft.com> wrote in message
> news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
> > Hello,
> > I have implemented SQL Server session state in my application however I am
> > having some problems. Simple objects stored in Session state are fine and
> > are
> > handled by .NET, however when I try to store more complex objects such as
> > an
> > ArrayList in session state I am not able to figure out exactly what I have
> > to
> > do to serialize and deserialize the object.
> > There doesn't seem to be any code examples around when it comes to
> > serializing session objects. Could anyone provide me with some code that
> > would help?
> > I have managed to successfully serialize and deserialize an object to a
> > file
> > but I am specifically looking to serialize the object to session state.
> > Thanks,
> > Gary
>

Serialize Object in Session?

Is it recommended to serialize a custom object when putting it in session?

I have a User object with properties ID, FirstName, LastName, and an
array of Permissions which I would like to keep in session. Should I
first serialize it to put it in session? I read that this is not
necessary, but I'm wondering about memory usage and performance. I
realize that serializing/deserializing the object will take time, but
will the serialized object consume less memory than the non serialized
object? If so, will it be significant. Thanks.> Is it recommended to serialize a custom object when putting it in session?

No.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Neither a follower nor a lender be.

"nick" <nickgieschen@.hotmail.com> wrote in message
news:305cab98.0308201022.164480d@.posting.google.co m...
> Is it recommended to serialize a custom object when putting it in session?
> I have a User object with properties ID, FirstName, LastName, and an
> array of Permissions which I would like to keep in session. Should I
> first serialize it to put it in session? I read that this is not
> necessary, but I'm wondering about memory usage and performance. I
> realize that serializing/deserializing the object will take time, but
> will the serialized object consume less memory than the non serialized
> object? If so, will it be significant. Thanks.
Serialize objects can recreate themselves from the stream.

So usually serialized representation of the object takes up more space than
object itself.

George.

"nick" <nickgieschen@.hotmail.com> wrote in message
news:305cab98.0308201022.164480d@.posting.google.co m...
> Is it recommended to serialize a custom object when putting it in session?
> I have a User object with properties ID, FirstName, LastName, and an
> array of Permissions which I would like to keep in session. Should I
> first serialize it to put it in session? I read that this is not
> necessary, but I'm wondering about memory usage and performance. I
> realize that serializing/deserializing the object will take time, but
> will the serialized object consume less memory than the non serialized
> object? If so, will it be significant. Thanks.

Serialize session state & OutOfMemoryError?

I have an application running on a 3 server webfarm running Windows 2003 with
SQLServer Session state. After running for several hours, I started getting
the following error. When I access each app individually, only one of the
servers seems to return this error when I step through a sequence. I was
told that I'm trying to store an object not marked as Serializable but I've
tested this on a dev machine storing session variables without any problems,
plus it works for several hours before I have issues. I think something else
is the root of this error but I don't know where to look exactly.

Server Error in '/' Application.
------------------------

Unable to serialize the session state. Please note that non-serializable
objects or MarshalByRef objects are not permitted when session state mode is
'StateServer' or 'SQLServer'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Web.HttpException: Unable to serialize the session
state. Please note that non-serializable objects or MarshalByRef objects are
not permitted when session state mode is 'StateServer' or 'SQLServer'.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:

[OutOfMemoryException: Exception of type System.OutOfMemoryException was
thrown.]

[HttpException (0x80004005): Unable to serialize the session state. Please
note that non-serializable objects or MarshalByRef objects are not permitted
when session state mode is 'StateServer' or 'SQLServer'.]
System.Web.Util.AltSerialization.WriteValueToStrea m(Object value,
BinaryWriter writer) +1711
System.Web.SessionState.SessionDictionary.Serializ e(BinaryWriter writer)
+148
System.Web.SessionState.StateClientManager.Seriali ze(SessionStateItem
item, Stream stream) +146

System.Web.SessionState.SqlStateClientManager.Syst em.Web.SessionState.IStateClientManager.Set(String id, SessionStateItem item, Boolean inStorage) +126
System.Web.SessionState.SessionStateModule.OnRelea seState(Object source,
EventArgs eventArgs) +465

System.Web.SyncEventExecutionStep.System.Web.HttpA pplication+IExecutionStep.Execute() +60
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +87many objects are serialiable until an unserialiable property is set, or an
unserialiable object is added.

-- bruce (sqlwork.com)

"Dave" <Dave@.discussions.microsoft.com> wrote in message
news:F64A9CC1-7B9B-411A-A8FB-1B9CF6C0FFEB@.microsoft.com...
>I have an application running on a 3 server webfarm running Windows 2003
>with
> SQLServer Session state. After running for several hours, I started
> getting
> the following error. When I access each app individually, only one of the
> servers seems to return this error when I step through a sequence. I was
> told that I'm trying to store an object not marked as Serializable but
> I've
> tested this on a dev machine storing session variables without any
> problems,
> plus it works for several hours before I have issues. I think something
> else
> is the root of this error but I don't know where to look exactly.
> Server Error in '/' Application.
> ------------------------
> Unable to serialize the session state. Please note that non-serializable
> objects or MarshalByRef objects are not permitted when session state mode
> is
> 'StateServer' or 'SQLServer'.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about
> the error and where it originated in the code.
> Exception Details: System.Web.HttpException: Unable to serialize the
> session
> state. Please note that non-serializable objects or MarshalByRef objects
> are
> not permitted when session state mode is 'StateServer' or 'SQLServer'.
> Source Error:
> An unhandled exception was generated during the execution of the current
> web
> request. Information regarding the origin and location of the exception
> can
> be identified using the exception stack trace below.
> Stack Trace:
>
> [OutOfMemoryException: Exception of type System.OutOfMemoryException was
> thrown.]
> [HttpException (0x80004005): Unable to serialize the session state. Please
> note that non-serializable objects or MarshalByRef objects are not
> permitted
> when session state mode is 'StateServer' or 'SQLServer'.]
> System.Web.Util.AltSerialization.WriteValueToStrea m(Object value,
> BinaryWriter writer) +1711
> System.Web.SessionState.SessionDictionary.Serializ e(BinaryWriter writer)
> +148
> System.Web.SessionState.StateClientManager.Seriali ze(SessionStateItem
> item, Stream stream) +146
> System.Web.SessionState.SqlStateClientManager.Syst em.Web.SessionState.IStateClientManager.Set(String
> id, SessionStateItem item, Boolean inStorage) +126
> System.Web.SessionState.SessionStateModule.OnRelea seState(Object source,
> EventArgs eventArgs) +465
> System.Web.SyncEventExecutionStep.System.Web.HttpA pplication+IExecutionStep.Execute()
> +60
> System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
> completedSynchronously) +87
Bruce,

Sorry, can you expand on that? If I'm adding a dataset to my session and a
few hours into the day I start to get this error on one of the servers, I'm
not sure how that it explains the problem

Thanks.

"Bruce Barker" wrote:

> many objects are serialiable until an unserialiable property is set, or an
> unserialiable object is added.
>
> -- bruce (sqlwork.com)
>
> "Dave" <Dave@.discussions.microsoft.com> wrote in message
> news:F64A9CC1-7B9B-411A-A8FB-1B9CF6C0FFEB@.microsoft.com...
> >I have an application running on a 3 server webfarm running Windows 2003
> >with
> > SQLServer Session state. After running for several hours, I started
> > getting
> > the following error. When I access each app individually, only one of the
> > servers seems to return this error when I step through a sequence. I was
> > told that I'm trying to store an object not marked as Serializable but
> > I've
> > tested this on a dev machine storing session variables without any
> > problems,
> > plus it works for several hours before I have issues. I think something
> > else
> > is the root of this error but I don't know where to look exactly.
> > Server Error in '/' Application.
> > ------------------------
> > Unable to serialize the session state. Please note that non-serializable
> > objects or MarshalByRef objects are not permitted when session state mode
> > is
> > 'StateServer' or 'SQLServer'.
> > Description: An unhandled exception occurred during the execution of the
> > current web request. Please review the stack trace for more information
> > about
> > the error and where it originated in the code.
> > Exception Details: System.Web.HttpException: Unable to serialize the
> > session
> > state. Please note that non-serializable objects or MarshalByRef objects
> > are
> > not permitted when session state mode is 'StateServer' or 'SQLServer'.
> > Source Error:
> > An unhandled exception was generated during the execution of the current
> > web
> > request. Information regarding the origin and location of the exception
> > can
> > be identified using the exception stack trace below.
> > Stack Trace:
> > [OutOfMemoryException: Exception of type System.OutOfMemoryException was
> > thrown.]
> > [HttpException (0x80004005): Unable to serialize the session state. Please
> > note that non-serializable objects or MarshalByRef objects are not
> > permitted
> > when session state mode is 'StateServer' or 'SQLServer'.]
> > System.Web.Util.AltSerialization.WriteValueToStrea m(Object value,
> > BinaryWriter writer) +1711
> > System.Web.SessionState.SessionDictionary.Serializ e(BinaryWriter writer)
> > +148
> > System.Web.SessionState.StateClientManager.Seriali ze(SessionStateItem
> > item, Stream stream) +146
> > System.Web.SessionState.SqlStateClientManager.Syst em.Web.SessionState.IStateClientManager.Set(String
> > id, SessionStateItem item, Boolean inStorage) +126
> > System.Web.SessionState.SessionStateModule.OnRelea seState(Object source,
> > EventArgs eventArgs) +465
> > System.Web.SyncEventExecutionStep.System.Web.HttpA pplication+IExecutionStep.Execute()
> > +60
> > System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
> > completedSynchronously) +87
>

Serialize session state & OutOfMemoryError?

I have an application running on a 3 server webfarm running Windows 2003 wit
h
SQLServer Session state. After running for several hours, I started getting
the following error. When I access each app individually, only one of the
servers seems to return this error when I step through a sequence. I was
told that I'm trying to store an object not marked as Serializable but I've
tested this on a dev machine storing session variables without any problems,
plus it works for several hours before I have issues. I think something els
e
is the root of this error but I don't know where to look exactly.
Server Error in '/' Application.
----
--
Unable to serialize the session state. Please note that non-serializable
objects or MarshalByRef objects are not permitted when session state mode is
'StateServer' or 'SQLServer'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information abou
t
the error and where it originated in the code.
Exception Details: System.Web.HttpException: Unable to serialize the session
state. Please note that non-serializable objects or MarshalByRef objects are
not permitted when session state mode is 'StateServer' or 'SQLServer'.
Source Error:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.
Stack Trace:
[OutOfMemoryException: Exception of type System.OutOfMemoryException was
thrown.]
[HttpException (0x80004005): Unable to serialize the session state. Please
note that non-serializable objects or MarshalByRef objects are not permitted
when session state mode is 'StateServer' or 'SQLServer'.]
System.Web.Util.AltSerialization.WriteValueToStream(Object value,
BinaryWriter writer) +1711
System.Web.SessionState.SessionDictionary.Serialize(BinaryWriter writer)
+148
System.Web.SessionState.StateClientManager.Serialize(SessionStateItem
item, Stream stream) +146
System.Web.SessionState.SqlStateClientManager.System.Web.SessionState.IState
ClientManager.Set(String id, SessionStateItem item, Boolean inStorage) +126
System.Web.SessionState.SessionStateModule.OnReleaseState(Object source,
EventArgs eventArgs) +465
System.Web.SyncEventExecutionStep.System.Web.HttpApplication+IExecutionStep.
Execute() +60
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +87many objects are serialiable until an unserialiable property is set, or an
unserialiable object is added.
-- bruce (sqlwork.com)
"Dave" <Dave@.discussions.microsoft.com> wrote in message
news:F64A9CC1-7B9B-411A-A8FB-1B9CF6C0FFEB@.microsoft.com...
>I have an application running on a 3 server webfarm running Windows 2003
>with
> SQLServer Session state. After running for several hours, I started
> getting
> the following error. When I access each app individually, only one of the
> servers seems to return this error when I step through a sequence. I was
> told that I'm trying to store an object not marked as Serializable but
> I've
> tested this on a dev machine storing session variables without any
> problems,
> plus it works for several hours before I have issues. I think something
> else
> is the root of this error but I don't know where to look exactly.
> Server Error in '/' Application.
> ----
--
> Unable to serialize the session state. Please note that non-serializable
> objects or MarshalByRef objects are not permitted when session state mode
> is
> 'StateServer' or 'SQLServer'.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about
> the error and where it originated in the code.
> Exception Details: System.Web.HttpException: Unable to serialize the
> session
> state. Please note that non-serializable objects or MarshalByRef objects
> are
> not permitted when session state mode is 'StateServer' or 'SQLServer'.
> Source Error:
> An unhandled exception was generated during the execution of the current
> web
> request. Information regarding the origin and location of the exception
> can
> be identified using the exception stack trace below.
> Stack Trace:
>
> [OutOfMemoryException: Exception of type System.OutOfMemoryException was
> thrown.]
> [HttpException (0x80004005): Unable to serialize the session state. Please
> note that non-serializable objects or MarshalByRef objects are not
> permitted
> when session state mode is 'StateServer' or 'SQLServer'.]
> System.Web.Util.AltSerialization.WriteValueToStream(Object value,
> BinaryWriter writer) +1711
> System.Web.SessionState.SessionDictionary.Serialize(BinaryWriter writer)
> +148
> System.Web.SessionState.StateClientManager.Serialize(SessionStateItem
> item, Stream stream) +146
> System.Web.SessionState.SqlStateClientManager.System.Web.SessionState.ISta
teClientManager.Set(String
> id, SessionStateItem item, Boolean inStorage) +126
> System.Web.SessionState.SessionStateModule.OnReleaseState(Object source,
> EventArgs eventArgs) +465
> System.Web.SyncEventExecutionStep.System.Web.HttpApplication+IExecutionSte
p.Execute()
> +60
> System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
> completedSynchronously) +87
>
>
Bruce,
Sorry, can you expand on that? If I'm adding a dataset to my session and a
few hours into the day I start to get this error on one of the servers, I'm
not sure how that it explains the problem
Thanks.
"Bruce Barker" wrote:

> many objects are serialiable until an unserialiable property is set, or an
> unserialiable object is added.
>
> -- bruce (sqlwork.com)
>
> "Dave" <Dave@.discussions.microsoft.com> wrote in message
> news:F64A9CC1-7B9B-411A-A8FB-1B9CF6C0FFEB@.microsoft.com...
>
>

Serializing an object from a DLL

I am using SQL to hold session state. My problem is that I have an object
that I want to store in Session State. I can not mark the class it comes from
as Serializable because it is from a DLL that I do not have the code for.
There must be an easy way to do this I just can't figure it out.

This is the code that Serializes the item that I want to place in a Session.

private string Serialize(SessionStateItemCollection items)
{
MemoryStream ms = new MemoryStream();
BinaryWriter writer = new BinaryWriter(ms);

if (items != null)
items.Serialize(writer);

writer.Close();

return Convert.ToBase64String(ms.ToArray());
}

I'd really appreciate anyone who could help.unless its sealed, make a new object that inherits from it, and enable
serialization.

the underlying object may not really support serialization (use of unmanged
code, active streams / connections, non-serializable objects). in this case
you can write a custom serializier read/write out the properties, and
perform required initialization.

-- bruce (sqlwork.com)

"Harry" wrote:

Quote:

Originally Posted by

I am using SQL to hold session state. My problem is that I have an object
that I want to store in Session State. I can not mark the class it comes from
as Serializable because it is from a DLL that I do not have the code for.
There must be an easy way to do this I just can't figure it out.
>
>
This is the code that Serializes the item that I want to place in a Session.
>
private string Serialize(SessionStateItemCollection items)
{
MemoryStream ms = new MemoryStream();
BinaryWriter writer = new BinaryWriter(ms);
>
if (items != null)
items.Serialize(writer);
>
writer.Close();
>
return Convert.ToBase64String(ms.ToArray());
}
>
I'd really appreciate anyone who could help.

Serializing an object from a DLL

I am using SQL to hold session state. My problem is that I have an object
that I want to store in Session State. I can not mark the class it comes fro
m
as Serializable because it is from a DLL that I do not have the code for.
There must be an easy way to do this I just can't figure it out.
This is the code that Serializes the item that I want to place in a Session.
private string Serialize(SessionStateItemCollection items)
{
MemoryStream ms = new MemoryStream();
BinaryWriter writer = new BinaryWriter(ms);
if (items != null)
items.Serialize(writer);
writer.Close();
return Convert.ToBase64String(ms.ToArray());
}
I'd really appreciate anyone who could help.unless its sealed, make a new object that inherits from it, and enable
serialization.
the underlying object may not really support serialization (use of unmanged
code, active streams / connections, non-serializable objects). in this case
you can write a custom serializier read/write out the properties, and
perform required initialization.
-- bruce (sqlwork.com)
"Harry" wrote:

> I am using SQL to hold session state. My problem is that I have an object
> that I want to store in Session State. I can not mark the class it comes f
rom
> as Serializable because it is from a DLL that I do not have the code for.
> There must be an easy way to do this I just can't figure it out.
>
> This is the code that Serializes the item that I want to place in a Sessio
n.
> private string Serialize(SessionStateItemCollection items)
> {
> MemoryStream ms = new MemoryStream();
> BinaryWriter writer = new BinaryWriter(ms);
> if (items != null)
> items.Serialize(writer);
> writer.Close();
> return Convert.ToBase64String(ms.ToArray());
> }
> I'd really appreciate anyone who could help.

Serializing classes from Web Services

I have a situation where I need to serialize a few classes (that are
read from a C++ web service) to ViewState or to Session. When I try
to do this I get an error that the class is not Serializable. Clearly
it is, because it has to be serialized to XML in order to be passed
from the Web Service. But it seems that the ViewState serialization
is a different animal.
I've solved the problem in the past by creating a new class in the
aspnet web client (C#) that duplicates the class but is tagged as
[Serializable]. Then I have to have code to transfer the data from
the input class to the serializable one before I can save it.
This is a horrible waste of code, processing power, Client and user
memory, and programing time! Isn't there a better way to do this?
Thanks, RussThe webservice serializer doesn't depend on the [Serliaziable] attribute
because it uses a different routine to perform the serialization.
Pete
====
Audio compression components, DIB graphics controls, FastStrings
http://www.droopyeyes.com
Read or write articles on just about anything
http://www.HowToDoThings.com

Serializing classes from Web Services

I have a situation where I need to serialize a few classes (that are
read from a C++ web service) to ViewState or to Session. When I try
to do this I get an error that the class is not Serializable. Clearly
it is, because it has to be serialized to XML in order to be passed
from the Web Service. But it seems that the ViewState serialization
is a different animal.

I've solved the problem in the past by creating a new class in the
aspnet web client (C#) that duplicates the class but is tagged as
[Serializable]. Then I have to have code to transfer the data from
the input class to the serializable one before I can save it.

This is a horrible waste of code, processing power, Client and user
memory, and programing time! Isn't there a better way to do this?

Thanks, RussThe webservice serializer doesn't depend on the [Serliaziable] attribute
because it uses a different routine to perform the serialization.

--
Pete
====
Audio compression components, DIB graphics controls, FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com

Serializing classes derived from dataset

Hi,

I am trying to store various objects within session. Due
to the site being hosted in a web farm we are going to
have to use either State Server or SQL Server to persist
the data in session. All of the objects are classes which
inherit from a typed dataset.

Looking at MSDN I have found the following two (what I
believe to be) relevent statements (from article Object
Serialization in the .NET Framework):

"Derived classes should call the GetObjectData method on
the base object if the latter implements ISerializable"

and

"When you derive a new class from one that implements
ISerializable, the derived class must implement both the
constructor as well as the GetObjectData method if it has
any variables that need to be serialized."

Since the Dataset implements ISerializable the above
statements indicate that I should override the
GetObjectData method. However if I try and override this
method I get a compile error stating:

"sub 'GetObjectData' cannot be declared 'Overrides'
because it does not override a sub in a base class."

I am also unable to call the method GetObjectData on the
base class as it is not accessible.

The classes which I am trying to persist have their own
properties, some of which are themselves objects which
inherit from datasets.

If I create a test class which inherits from a typed
dataset, and which has two additional properites (named
Property1 and Property2) the following XML is persisted:

<?xml version="1.0" encoding="utf-16"?>
<xs:schema id="dsTemp"
targetNamespace="http://tempuri.org/dsTemp.xsd"
xmlns:mstns="http://tempuri.org/dsTemp.xsd"
xmlns="http://tempuri.org/dsTemp.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified"
elementFormDefault="qualified">
<xs:element name="dsTemp" msdata:IsDataSet="true"
msdata:Property1="1" msdata:Property2="Aidan">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="InvoiceHeader">
<xs:complexType>
<xs:sequence>
<xs:element name="InvoiceHeaderID"
msdata:ReadOnly="true" msdata:AutoIncrement="true"
type="xs:int" />
<xs:element name="POHeaderID" type="xs:int"
minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="dsTempKey1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:InvoiceHeader" />
<xs:field xpath="mstns:InvoiceHeaderID" />
</xs:unique>
</xs:element>
</xs:schema
Note that the properties have been serialized, but have
been serialized as "<xs:element name="dsTemp"
msdata:IsDataSet="true" msdata:Property1="1"
msdata:Property2="Aidan">"

I can find no way in which I can de-serialize these fields.

Can someone please explain how I can have a class which
inherits from a dataset, and which I can then serialize
and de-serialize without losing the properties.

Thanks in advance

AidanNote that the xml which should have been displayed
indicated that the properties were included in a dataset
element as

msdata:Property1="1"
msdata:Property2="Aidan"

>--Original Message--
>Hi,
>I am trying to store various objects within session. Due
>to the site being hosted in a web farm we are going to
>have to use either State Server or SQL Server to persist
>the data in session. All of the objects are classes
which
>inherit from a typed dataset.
>Looking at MSDN I have found the following two (what I
>believe to be) relevent statements (from article Object
>Serialization in the .NET Framework):
>"Derived classes should call the GetObjectData method on
>the base object if the latter implements ISerializable"
>and
>"When you derive a new class from one that implements
>ISerializable, the derived class must implement both the
>constructor as well as the GetObjectData method if it has
>any variables that need to be serialized."
>Since the Dataset implements ISerializable the above
>statements indicate that I should override the
>GetObjectData method. However if I try and override this
>method I get a compile error stating:
>"sub 'GetObjectData' cannot be declared 'Overrides'
>because it does not override a sub in a base class."
>I am also unable to call the method GetObjectData on the
>base class as it is not accessible.
>The classes which I am trying to persist have their own
>properties, some of which are themselves objects which
>inherit from datasets.
>If I create a test class which inherits from a typed
>dataset, and which has two additional properites (named
>Property1 and Property2) the following XML is persisted:
><?xml version="1.0" encoding="utf-16"?>
><xs:schema id="dsTemp"
>targetNamespace="http://tempuri.org/dsTemp.xsd"
>xmlns:mstns="http://tempuri.org/dsTemp.xsd"
>xmlns="http://tempuri.org/dsTemp.xsd"
>xmlns:xs="http://www.w3.org/2001/XMLSchema"
>xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
>attributeFormDefault="qualified"
>elementFormDefault="qualified">
> <xs:element name="dsTemp" msdata:IsDataSet="true"
>msdata:Property1="1" msdata:Property2="Aidan">
> <xs:complexType>
> <xs:choice maxOccurs="unbounded">
> <xs:element name="InvoiceHeader">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="InvoiceHeaderID"
>msdata:ReadOnly="true" msdata:AutoIncrement="true"
>type="xs:int" />
> <xs:element name="POHeaderID" type="xs:int"
>minOccurs="0" />
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:choice>
> </xs:complexType>
> <xs:unique name="dsTempKey1" msdata:PrimaryKey="true">
> <xs:selector xpath=".//mstns:InvoiceHeader" />
> <xs:field xpath="mstns:InvoiceHeaderID" />
> </xs:unique>
> </xs:element>
></xs:schema>
>Note that the properties have been serialized, but have
>been serialized as "<xs:element name="dsTemp"
>msdata:IsDataSet="true" msdata:Property1="1"
>msdata:Property2="Aidan">"
>I can find no way in which I can de-serialize these
fields.
>Can someone please explain how I can have a class which
>inherits from a dataset, and which I can then serialize
>and de-serialize without losing the properties.
>Thanks in advance
>Aidan
>.

Serializing drop-down list data sources in Session State

Hello,

I have several drop-down lists on my ASP.NET page. I need to keep data
sources of these lists in Session State.
What would be the most effective method to serialize this kind of data
structures?

Thanks for any hints,
Leszek TaratutaUse DataTable or HashTable, they are serializable.

"Leszek Taratuta" <ads@.taratuta.net> wrote in message
news:%23byMha%23yEHA.2200@.TK2MSFTNGP09.phx.gbl...
> Hello,
> I have several drop-down lists on my ASP.NET page. I need to keep data
> sources of these lists in Session State.
> What would be the most effective method to serialize this kind of data
> structures?
> Thanks for any hints,
> Leszek Taratuta
Thanks, but this what I have already tried. The problem is the ListItem
class is not serializable.

I have created my own ListItem-like class (serializable) and copied
drop-down list data sources (using my ListItem class) to ArrayLists. Then I
put the array lists into a hash table with keys as drop-down lists' ids.
This solution does not work. When I try to deserialize such a structure,
..NET gives me an exception that the type version has been changed and it is
not possible to deserialize data. I think the type is too complex for
serialization (custom ListItem-like objects within ArrayLists within a
Hashtable).

Any other suggestions,
Leszek

"Kikoz" <kikoz@.hotmail.com> wrote in message
news:O14Fov#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> Use DataTable or HashTable, they are serializable.
> "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> news:%23byMha%23yEHA.2200@.TK2MSFTNGP09.phx.gbl...
> > Hello,
> > I have several drop-down lists on my ASP.NET page. I need to keep data
> > sources of these lists in Session State.
> > What would be the most effective method to serialize this kind of data
> > structures?
> > Thanks for any hints,
> > Leszek Taratuta
You didn't say you wanted to serialize Controls, you said you wanted to
serialize the DataSource that you're binding to. A ListItem is a UI Control,
and there's no need (or even a good reason) to serialize it. Just store the
DataTable in Session and bind to it.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Leszek Taratuta" <ads@.taratuta.net> wrote in message
news:OAlaM5#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> Thanks, but this what I have already tried. The problem is the ListItem
> class is not serializable.
> I have created my own ListItem-like class (serializable) and copied
> drop-down list data sources (using my ListItem class) to ArrayLists. Then
I
> put the array lists into a hash table with keys as drop-down lists' ids.
> This solution does not work. When I try to deserialize such a structure,
> .NET gives me an exception that the type version has been changed and it
is
> not possible to deserialize data. I think the type is too complex for
> serialization (custom ListItem-like objects within ArrayLists within a
> Hashtable).
> Any other suggestions,
> Leszek
> "Kikoz" <kikoz@.hotmail.com> wrote in message
> news:O14Fov#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> > Use DataTable or HashTable, they are serializable.
> > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > news:%23byMha%23yEHA.2200@.TK2MSFTNGP09.phx.gbl...
> > > Hello,
> > > > I have several drop-down lists on my ASP.NET page. I need to keep data
> > > sources of these lists in Session State.
> > > What would be the most effective method to serialize this kind of data
> > > structures?
> > > > Thanks for any hints,
> > > Leszek Taratuta
> >
Live sample:

(If this ddl doesn't depend on specific user, store it in Application or
Cache):

const string SOURCE_NAME = "SourceName";
private DataTable GetThatFreakingSource()
{
if(Application[SOURCE_NAME] == null)
{
DataTable tbl = GetThatTableFromDbOrSomething();
Application[SOURCE_NAME] = tbl;
return tbl;
}
return (DataTable)Application[SOURCE_NAME];
}
private void BindThatDdl()
{
ddl.DataSource = GetThatFreakingSource();
ddl.DataBind();
}

Done. In sort, when you box Application[SOURCE_NAME] to DataTable (last line
in the first method) that's where serilization takes place. Automatically.

Enjoy :)

"Leszek Taratuta" <ads@.taratuta.net> wrote in message
news:OAlaM5%23yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> Thanks, but this what I have already tried. The problem is the ListItem
> class is not serializable.
> I have created my own ListItem-like class (serializable) and copied
> drop-down list data sources (using my ListItem class) to ArrayLists. Then
> I
> put the array lists into a hash table with keys as drop-down lists' ids.
> This solution does not work. When I try to deserialize such a structure,
> .NET gives me an exception that the type version has been changed and it
> is
> not possible to deserialize data. I think the type is too complex for
> serialization (custom ListItem-like objects within ArrayLists within a
> Hashtable).
> Any other suggestions,
> Leszek
> "Kikoz" <kikoz@.hotmail.com> wrote in message
> news:O14Fov#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
>> Use DataTable or HashTable, they are serializable.
>>
>> "Leszek Taratuta" <ads@.taratuta.net> wrote in message
>> news:%23byMha%23yEHA.2200@.TK2MSFTNGP09.phx.gbl...
>> > Hello,
>>> > I have several drop-down lists on my ASP.NET page. I need to keep data
>> > sources of these lists in Session State.
>> > What would be the most effective method to serialize this kind of data
>> > structures?
>>> > Thanks for any hints,
>> > Leszek Taratuta
>>>>
>>
Thanks. I forgot the ListItems are controls.
The situation is that my data sources are not DataTables. I have ArrayLists
filled with ListItems.
The problem is I cannot serialize this kind of ArrayLists to session state
kept in state server.

Thanks,
Leszek

"Kevin Spencer" <kspencer@.takempis.com> wrote in message
news:uC0bhX$yEHA.336@.TK2MSFTNGP10.phx.gbl...
> You didn't say you wanted to serialize Controls, you said you wanted to
> serialize the DataSource that you're binding to. A ListItem is a UI
Control,
> and there's no need (or even a good reason) to serialize it. Just store
the
> DataTable in Session and bind to it.
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Neither a follower
> nor a lender be.
> "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> news:OAlaM5#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> > Thanks, but this what I have already tried. The problem is the ListItem
> > class is not serializable.
> > I have created my own ListItem-like class (serializable) and copied
> > drop-down list data sources (using my ListItem class) to ArrayLists.
Then
> I
> > put the array lists into a hash table with keys as drop-down lists' ids.
> > This solution does not work. When I try to deserialize such a structure,
> > .NET gives me an exception that the type version has been changed and it
> is
> > not possible to deserialize data. I think the type is too complex for
> > serialization (custom ListItem-like objects within ArrayLists within a
> > Hashtable).
> > Any other suggestions,
> > Leszek
> > "Kikoz" <kikoz@.hotmail.com> wrote in message
> > news:O14Fov#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> > > Use DataTable or HashTable, they are serializable.
> > > > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > news:%23byMha%23yEHA.2200@.TK2MSFTNGP09.phx.gbl...
> > > > Hello,
> > > > > > I have several drop-down lists on my ASP.NET page. I need to keep
data
> > > > sources of these lists in Session State.
> > > > What would be the most effective method to serialize this kind of
data
> > > > structures?
> > > > > > Thanks for any hints,
> > > > Leszek Taratuta
> > > > > >
I think you complicate things for no obvious reason :) I may be totally
wrong, it all depends on particular situation, but this is what it seems
like. Much easier to store data in serializable object like DataTable and
then keep it on server, even if that would require to put your data in such
table first.

"Leszek Taratuta" <ads@.taratuta.net> wrote in message
news:OEVLPz$yEHA.1412@.tk2msftngp13.phx.gbl...
> Thanks. I forgot the ListItems are controls.
> The situation is that my data sources are not DataTables. I have
> ArrayLists
> filled with ListItems.
> The problem is I cannot serialize this kind of ArrayLists to session state
> kept in state server.
> Thanks,
> Leszek
> "Kevin Spencer" <kspencer@.takempis.com> wrote in message
> news:uC0bhX$yEHA.336@.TK2MSFTNGP10.phx.gbl...
>> You didn't say you wanted to serialize Controls, you said you wanted to
>> serialize the DataSource that you're binding to. A ListItem is a UI
> Control,
>> and there's no need (or even a good reason) to serialize it. Just store
> the
>> DataTable in Session and bind to it.
>>
>> --
>> HTH,
>> Kevin Spencer
>> .Net Developer
>> Microsoft MVP
>> Neither a follower
>> nor a lender be.
>>
>> "Leszek Taratuta" <ads@.taratuta.net> wrote in message
>> news:OAlaM5#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
>> > Thanks, but this what I have already tried. The problem is the ListItem
>> > class is not serializable.
>>> > I have created my own ListItem-like class (serializable) and copied
>> > drop-down list data sources (using my ListItem class) to ArrayLists.
> Then
>> I
>> > put the array lists into a hash table with keys as drop-down lists'
>> > ids.
>> > This solution does not work. When I try to deserialize such a
>> > structure,
>> > .NET gives me an exception that the type version has been changed and
>> > it
>> is
>> > not possible to deserialize data. I think the type is too complex for
>> > serialization (custom ListItem-like objects within ArrayLists within a
>> > Hashtable).
>>> > Any other suggestions,
>> > Leszek
>>> > "Kikoz" <kikoz@.hotmail.com> wrote in message
>> > news:O14Fov#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
>> > > Use DataTable or HashTable, they are serializable.
>> >> > > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
>> > > news:%23byMha%23yEHA.2200@.TK2MSFTNGP09.phx.gbl...
>> > > > Hello,
>> > >> > > > I have several drop-down lists on my ASP.NET page. I need to keep
> data
>> > > > sources of these lists in Session State.
>> > > > What would be the most effective method to serialize this kind of
> data
>> > > > structures?
>> > >> > > > Thanks for any hints,
>> > > > Leszek Taratuta
>> > >> > >> >> >>>>
>>
Well, I know it is much easier to store data in serializable object like
DataTable but I work in a team, and what I receive from the data layer is
ArrayList containing ListItems.
For now the only resonable solution is to convert the ArrayLists to
DataTables. It is not efficient though. I thought it would be any other more
appropriate way to store this kind of data. Any kind of serialization from
ArrayLists to strings or so, and then deserialization.

Thanks,
Leszek

"Kikoz" <kikoz@.hotmail.com> wrote in message
news:Obu#I3$yEHA.1292@.TK2MSFTNGP10.phx.gbl...
> I think you complicate things for no obvious reason :) I may be totally
> wrong, it all depends on particular situation, but this is what it seems
> like. Much easier to store data in serializable object like DataTable and
> then keep it on server, even if that would require to put your data in
such
> table first.
>
> "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> news:OEVLPz$yEHA.1412@.tk2msftngp13.phx.gbl...
> > Thanks. I forgot the ListItems are controls.
> > The situation is that my data sources are not DataTables. I have
> > ArrayLists
> > filled with ListItems.
> > The problem is I cannot serialize this kind of ArrayLists to session
state
> > kept in state server.
> > Thanks,
> > Leszek
> > "Kevin Spencer" <kspencer@.takempis.com> wrote in message
> > news:uC0bhX$yEHA.336@.TK2MSFTNGP10.phx.gbl...
> >> You didn't say you wanted to serialize Controls, you said you wanted to
> >> serialize the DataSource that you're binding to. A ListItem is a UI
> > Control,
> >> and there's no need (or even a good reason) to serialize it. Just store
> > the
> >> DataTable in Session and bind to it.
> >>
> >> --
> >> HTH,
> >> Kevin Spencer
> >> .Net Developer
> >> Microsoft MVP
> >> Neither a follower
> >> nor a lender be.
> >>
> >> "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> >> news:OAlaM5#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> >> > Thanks, but this what I have already tried. The problem is the
ListItem
> >> > class is not serializable.
> >> >> > I have created my own ListItem-like class (serializable) and copied
> >> > drop-down list data sources (using my ListItem class) to ArrayLists.
> > Then
> >> I
> >> > put the array lists into a hash table with keys as drop-down lists'
> >> > ids.
> >> > This solution does not work. When I try to deserialize such a
> >> > structure,
> >> > .NET gives me an exception that the type version has been changed and
> >> > it
> >> is
> >> > not possible to deserialize data. I think the type is too complex for
> >> > serialization (custom ListItem-like objects within ArrayLists within
a
> >> > Hashtable).
> >> >> > Any other suggestions,
> >> > Leszek
> >> >> > "Kikoz" <kikoz@.hotmail.com> wrote in message
> >> > news:O14Fov#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> >> > > Use DataTable or HashTable, they are serializable.
> >> > >> > > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> >> > > news:%23byMha%23yEHA.2200@.TK2MSFTNGP09.phx.gbl...
> >> > > > Hello,
> >> > > >> > > > I have several drop-down lists on my ASP.NET page. I need to keep
> > data
> >> > > > sources of these lists in Session State.
> >> > > > What would be the most effective method to serialize this kind of
> > data
> >> > > > structures?
> >> > > >> > > > Thanks for any hints,
> >> > > > Leszek Taratuta
> >> > > >> > > >> > >> > >> >> >>
> >>
Well, Leszek, it seems that the wrong person is asking this question of the
newsgroup. Whoever is sending you ArrayLists of ListItems is the one who
needs the help!

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Leszek Taratuta" <ads@.taratuta.net> wrote in message
news:#AIc3TAzEHA.1292@.TK2MSFTNGP10.phx.gbl...
> Well, I know it is much easier to store data in serializable object like
> DataTable but I work in a team, and what I receive from the data layer is
> ArrayList containing ListItems.
> For now the only resonable solution is to convert the ArrayLists to
> DataTables. It is not efficient though. I thought it would be any other
more
> appropriate way to store this kind of data. Any kind of serialization from
> ArrayLists to strings or so, and then deserialization.
> Thanks,
> Leszek
> "Kikoz" <kikoz@.hotmail.com> wrote in message
> news:Obu#I3$yEHA.1292@.TK2MSFTNGP10.phx.gbl...
> > I think you complicate things for no obvious reason :) I may be totally
> > wrong, it all depends on particular situation, but this is what it seems
> > like. Much easier to store data in serializable object like DataTable
and
> > then keep it on server, even if that would require to put your data in
> such
> > table first.
> > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > news:OEVLPz$yEHA.1412@.tk2msftngp13.phx.gbl...
> > > Thanks. I forgot the ListItems are controls.
> > > The situation is that my data sources are not DataTables. I have
> > > ArrayLists
> > > filled with ListItems.
> > > The problem is I cannot serialize this kind of ArrayLists to session
> state
> > > kept in state server.
> > > > Thanks,
> > > Leszek
> > > > "Kevin Spencer" <kspencer@.takempis.com> wrote in message
> > > news:uC0bhX$yEHA.336@.TK2MSFTNGP10.phx.gbl...
> > >> You didn't say you wanted to serialize Controls, you said you wanted
to
> > >> serialize the DataSource that you're binding to. A ListItem is a UI
> > > Control,
> > >> and there's no need (or even a good reason) to serialize it. Just
store
> > > the
> > >> DataTable in Session and bind to it.
> > >>
> > >> --
> > >> HTH,
> > >> Kevin Spencer
> > >> .Net Developer
> > >> Microsoft MVP
> > >> Neither a follower
> > >> nor a lender be.
> > >>
> > >> "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > >> news:OAlaM5#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> > >> > Thanks, but this what I have already tried. The problem is the
> ListItem
> > >> > class is not serializable.
> > >> > >> > I have created my own ListItem-like class (serializable) and copied
> > >> > drop-down list data sources (using my ListItem class) to
ArrayLists.
> > > Then
> > >> I
> > >> > put the array lists into a hash table with keys as drop-down lists'
> > >> > ids.
> > >> > This solution does not work. When I try to deserialize such a
> > >> > structure,
> > >> > .NET gives me an exception that the type version has been changed
and
> > >> > it
> > >> is
> > >> > not possible to deserialize data. I think the type is too complex
for
> > >> > serialization (custom ListItem-like objects within ArrayLists
within
> a
> > >> > Hashtable).
> > >> > >> > Any other suggestions,
> > >> > Leszek
> > >> > >> > "Kikoz" <kikoz@.hotmail.com> wrote in message
> > >> > news:O14Fov#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> > >> > > Use DataTable or HashTable, they are serializable.
> > >> > > >> > > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > >> > > news:%23byMha%23yEHA.2200@.TK2MSFTNGP09.phx.gbl...
> > >> > > > Hello,
> > >> > > > >> > > > I have several drop-down lists on my ASP.NET page. I need to
keep
> > > data
> > >> > > > sources of these lists in Session State.
> > >> > > > What would be the most effective method to serialize this kind
of
> > > data
> > >> > > > structures?
> > >> > > > >> > > > Thanks for any hints,
> > >> > > > Leszek Taratuta
> > >> > > > >> > > > >> > > >> > > >> > >> > >>
> > >>
> >
Thank you. I am going to talk with the guy who creates the data layer.

BTW
What could be the best alternative to get drop-down list data sources from
the data layer? DataTables are pretty heavy. Any other possibilities.

Thanks,

Leszek

"Kevin Spencer" <kspencer@.takempis.com> wrote in message
news:#raiusAzEHA.1452@.TK2MSFTNGP11.phx.gbl...
> Well, Leszek, it seems that the wrong person is asking this question of
the
> newsgroup. Whoever is sending you ArrayLists of ListItems is the one who
> needs the help!
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Neither a follower
> nor a lender be.
> "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> news:#AIc3TAzEHA.1292@.TK2MSFTNGP10.phx.gbl...
> > Well, I know it is much easier to store data in serializable object like
> > DataTable but I work in a team, and what I receive from the data layer
is
> > ArrayList containing ListItems.
> > For now the only resonable solution is to convert the ArrayLists to
> > DataTables. It is not efficient though. I thought it would be any other
> more
> > appropriate way to store this kind of data. Any kind of serialization
from
> > ArrayLists to strings or so, and then deserialization.
> > Thanks,
> > Leszek
> > "Kikoz" <kikoz@.hotmail.com> wrote in message
> > news:Obu#I3$yEHA.1292@.TK2MSFTNGP10.phx.gbl...
> > > I think you complicate things for no obvious reason :) I may be
totally
> > > wrong, it all depends on particular situation, but this is what it
seems
> > > like. Much easier to store data in serializable object like DataTable
> and
> > > then keep it on server, even if that would require to put your data in
> > such
> > > table first.
> > > > > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > news:OEVLPz$yEHA.1412@.tk2msftngp13.phx.gbl...
> > > > Thanks. I forgot the ListItems are controls.
> > > > The situation is that my data sources are not DataTables. I have
> > > > ArrayLists
> > > > filled with ListItems.
> > > > The problem is I cannot serialize this kind of ArrayLists to session
> > state
> > > > kept in state server.
> > > > > > Thanks,
> > > > Leszek
> > > > > > "Kevin Spencer" <kspencer@.takempis.com> wrote in message
> > > > news:uC0bhX$yEHA.336@.TK2MSFTNGP10.phx.gbl...
> > > >> You didn't say you wanted to serialize Controls, you said you
wanted
> to
> > > >> serialize the DataSource that you're binding to. A ListItem is a UI
> > > > Control,
> > > >> and there's no need (or even a good reason) to serialize it. Just
> store
> > > > the
> > > >> DataTable in Session and bind to it.
> > > >>
> > > >> --
> > > >> HTH,
> > > >> Kevin Spencer
> > > >> .Net Developer
> > > >> Microsoft MVP
> > > >> Neither a follower
> > > >> nor a lender be.
> > > >>
> > > >> "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > >> news:OAlaM5#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> > > >> > Thanks, but this what I have already tried. The problem is the
> > ListItem
> > > >> > class is not serializable.
> > > >> > > >> > I have created my own ListItem-like class (serializable) and
copied
> > > >> > drop-down list data sources (using my ListItem class) to
> ArrayLists.
> > > > Then
> > > >> I
> > > >> > put the array lists into a hash table with keys as drop-down
lists'
> > > >> > ids.
> > > >> > This solution does not work. When I try to deserialize such a
> > > >> > structure,
> > > >> > .NET gives me an exception that the type version has been changed
> and
> > > >> > it
> > > >> is
> > > >> > not possible to deserialize data. I think the type is too complex
> for
> > > >> > serialization (custom ListItem-like objects within ArrayLists
> within
> > a
> > > >> > Hashtable).
> > > >> > > >> > Any other suggestions,
> > > >> > Leszek
> > > >> > > >> > "Kikoz" <kikoz@.hotmail.com> wrote in message
> > > >> > news:O14Fov#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> > > >> > > Use DataTable or HashTable, they are serializable.
> > > >> > > > >> > > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > >> > > news:%23byMha%23yEHA.2200@.TK2MSFTNGP09.phx.gbl...
> > > >> > > > Hello,
> > > >> > > > > >> > > > I have several drop-down lists on my ASP.NET page. I need to
> keep
> > > > data
> > > >> > > > sources of these lists in Session State.
> > > >> > > > What would be the most effective method to serialize this
kind
> of
> > > > data
> > > >> > > > structures?
> > > >> > > > > >> > > > Thanks for any hints,
> > > >> > > > Leszek Taratuta
> > > >> > > > > >> > > > > >> > > > >> > > > >> > > >> > > >>
> > > >>
> > > > > >
Hi Leszek,

First of all, as was mentioned earlier, ListItems are UI elements. A
well-designed Data Layer should NEVER work with UI elements. Why, even your
business layer shouldn't be working with UI elements. Only data structures
should come from the Data Layer. That would be raw primitve data, such as
integers, dates, and strings, DataSets, DataTables, and DataReaders. Now,
there is some controversy over returning DataReaders, so the next smallest
data structure (other than primitives) would be a DataTable, and it really
has a relatively small footprint. DataReaders are the smallest, but have
some issues, such as necessitating a constant Connection while in use, as
well as being forward-only, read-only, and not being serializable.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Leszek Taratuta" <ads@.taratuta.net> wrote in message
news:OIzVpPBzEHA.2568@.TK2MSFTNGP11.phx.gbl...
> Thank you. I am going to talk with the guy who creates the data layer.
> BTW
> What could be the best alternative to get drop-down list data sources from
> the data layer? DataTables are pretty heavy. Any other possibilities.
> Thanks,
> Leszek
> "Kevin Spencer" <kspencer@.takempis.com> wrote in message
> news:#raiusAzEHA.1452@.TK2MSFTNGP11.phx.gbl...
> > Well, Leszek, it seems that the wrong person is asking this question of
> the
> > newsgroup. Whoever is sending you ArrayLists of ListItems is the one who
> > needs the help!
> > --
> > HTH,
> > Kevin Spencer
> > .Net Developer
> > Microsoft MVP
> > Neither a follower
> > nor a lender be.
> > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > news:#AIc3TAzEHA.1292@.TK2MSFTNGP10.phx.gbl...
> > > Well, I know it is much easier to store data in serializable object
like
> > > DataTable but I work in a team, and what I receive from the data layer
> is
> > > ArrayList containing ListItems.
> > > For now the only resonable solution is to convert the ArrayLists to
> > > DataTables. It is not efficient though. I thought it would be any
other
> > more
> > > appropriate way to store this kind of data. Any kind of serialization
> from
> > > ArrayLists to strings or so, and then deserialization.
> > > > Thanks,
> > > Leszek
> > > > "Kikoz" <kikoz@.hotmail.com> wrote in message
> > > news:Obu#I3$yEHA.1292@.TK2MSFTNGP10.phx.gbl...
> > > > I think you complicate things for no obvious reason :) I may be
> totally
> > > > wrong, it all depends on particular situation, but this is what it
> seems
> > > > like. Much easier to store data in serializable object like
DataTable
> > and
> > > > then keep it on server, even if that would require to put your data
in
> > > such
> > > > table first.
> > > > > > > > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > > news:OEVLPz$yEHA.1412@.tk2msftngp13.phx.gbl...
> > > > > Thanks. I forgot the ListItems are controls.
> > > > > The situation is that my data sources are not DataTables. I have
> > > > > ArrayLists
> > > > > filled with ListItems.
> > > > > The problem is I cannot serialize this kind of ArrayLists to
session
> > > state
> > > > > kept in state server.
> > > > > > > > Thanks,
> > > > > Leszek
> > > > > > > > "Kevin Spencer" <kspencer@.takempis.com> wrote in message
> > > > > news:uC0bhX$yEHA.336@.TK2MSFTNGP10.phx.gbl...
> > > > >> You didn't say you wanted to serialize Controls, you said you
> wanted
> > to
> > > > >> serialize the DataSource that you're binding to. A ListItem is a
UI
> > > > > Control,
> > > > >> and there's no need (or even a good reason) to serialize it. Just
> > store
> > > > > the
> > > > >> DataTable in Session and bind to it.
> > > > >>
> > > > >> --
> > > > >> HTH,
> > > > >> Kevin Spencer
> > > > >> .Net Developer
> > > > >> Microsoft MVP
> > > > >> Neither a follower
> > > > >> nor a lender be.
> > > > >>
> > > > >> "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > > >> news:OAlaM5#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> > > > >> > Thanks, but this what I have already tried. The problem is the
> > > ListItem
> > > > >> > class is not serializable.
> > > > >> > > > >> > I have created my own ListItem-like class (serializable) and
> copied
> > > > >> > drop-down list data sources (using my ListItem class) to
> > ArrayLists.
> > > > > Then
> > > > >> I
> > > > >> > put the array lists into a hash table with keys as drop-down
> lists'
> > > > >> > ids.
> > > > >> > This solution does not work. When I try to deserialize such a
> > > > >> > structure,
> > > > >> > .NET gives me an exception that the type version has been
changed
> > and
> > > > >> > it
> > > > >> is
> > > > >> > not possible to deserialize data. I think the type is too
complex
> > for
> > > > >> > serialization (custom ListItem-like objects within ArrayLists
> > within
> > > a
> > > > >> > Hashtable).
> > > > >> > > > >> > Any other suggestions,
> > > > >> > Leszek
> > > > >> > > > >> > "Kikoz" <kikoz@.hotmail.com> wrote in message
> > > > >> > news:O14Fov#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> > > > >> > > Use DataTable or HashTable, they are serializable.
> > > > >> > > > > >> > > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > > >> > > news:%23byMha%23yEHA.2200@.TK2MSFTNGP09.phx.gbl...
> > > > >> > > > Hello,
> > > > >> > > > > > >> > > > I have several drop-down lists on my ASP.NET page. I need
to
> > keep
> > > > > data
> > > > >> > > > sources of these lists in Session State.
> > > > >> > > > What would be the most effective method to serialize this
> kind
> > of
> > > > > data
> > > > >> > > > structures?
> > > > >> > > > > > >> > > > Thanks for any hints,
> > > > >> > > > Leszek Taratuta
> > > > >> > > > > > >> > > > > > >> > > > > >> > > > > >> > > > >> > > > >>
> > > > >>
> > > > > > > > > > > >
Thanks a lot. It seems DataTable is the best solution.

In the meantime the database guy decided to fill ArrayLists not with
ListItems but with some user defined structures similar to ListItems:

public sealed class ItemData
{
public string name;
public int val;

public ItemData(string name, int val)
{
this.name = name;
this.val = val;
}
}

Now I need to populate drop-down lists manually using code like this:

// list - an ArrayList containing ItemDatas
// ddl - the drop-down list control
for ( int i = 0; i < list.Count; i++ )
{
ddl.Items.Add( new ListItem( ((ItemData) list[i]).Name, ((ItemData)
list[i]).Id.ToString() ) );
}

What do you think about such a solution? Is it any better than passing
DataTable? For sure it is more cumbersome in terms of populating the lists,
but the database guy wants the smallest possible footprint and ItemData
items are light (they are structures). But on the other hand they are
elements of ArrayList that boxes the sturcture elements (that are value
types) to have reference types.

So my question is which option is better DataTable or the custom-defined
ItemData elements contained in an ArrayList?

Thanks,
Leszek

"Kevin Spencer" <kspencer@.takempis.com> wrote in message
news:urNAYrBzEHA.3408@.tk2msftngp13.phx.gbl...
> Hi Leszek,
> First of all, as was mentioned earlier, ListItems are UI elements. A
> well-designed Data Layer should NEVER work with UI elements. Why, even
your
> business layer shouldn't be working with UI elements. Only data structures
> should come from the Data Layer. That would be raw primitve data, such as
> integers, dates, and strings, DataSets, DataTables, and DataReaders. Now,
> there is some controversy over returning DataReaders, so the next smallest
> data structure (other than primitives) would be a DataTable, and it really
> has a relatively small footprint. DataReaders are the smallest, but have
> some issues, such as necessitating a constant Connection while in use, as
> well as being forward-only, read-only, and not being serializable.
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Neither a follower
> nor a lender be.
> "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> news:OIzVpPBzEHA.2568@.TK2MSFTNGP11.phx.gbl...
> > Thank you. I am going to talk with the guy who creates the data layer.
> > BTW
> > What could be the best alternative to get drop-down list data sources
from
> > the data layer? DataTables are pretty heavy. Any other possibilities.
> > Thanks,
> > Leszek
> > "Kevin Spencer" <kspencer@.takempis.com> wrote in message
> > news:#raiusAzEHA.1452@.TK2MSFTNGP11.phx.gbl...
> > > Well, Leszek, it seems that the wrong person is asking this question
of
> > the
> > > newsgroup. Whoever is sending you ArrayLists of ListItems is the one
who
> > > needs the help!
> > > > --
> > > HTH,
> > > Kevin Spencer
> > > .Net Developer
> > > Microsoft MVP
> > > Neither a follower
> > > nor a lender be.
> > > > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > news:#AIc3TAzEHA.1292@.TK2MSFTNGP10.phx.gbl...
> > > > Well, I know it is much easier to store data in serializable object
> like
> > > > DataTable but I work in a team, and what I receive from the data
layer
> > is
> > > > ArrayList containing ListItems.
> > > > For now the only resonable solution is to convert the ArrayLists to
> > > > DataTables. It is not efficient though. I thought it would be any
> other
> > > more
> > > > appropriate way to store this kind of data. Any kind of
serialization
> > from
> > > > ArrayLists to strings or so, and then deserialization.
> > > > > > Thanks,
> > > > Leszek
> > > > > > "Kikoz" <kikoz@.hotmail.com> wrote in message
> > > > news:Obu#I3$yEHA.1292@.TK2MSFTNGP10.phx.gbl...
> > > > > I think you complicate things for no obvious reason :) I may be
> > totally
> > > > > wrong, it all depends on particular situation, but this is what it
> > seems
> > > > > like. Much easier to store data in serializable object like
> DataTable
> > > and
> > > > > then keep it on server, even if that would require to put your
data
> in
> > > > such
> > > > > table first.
> > > > > > > > > > > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > > > news:OEVLPz$yEHA.1412@.tk2msftngp13.phx.gbl...
> > > > > > Thanks. I forgot the ListItems are controls.
> > > > > > The situation is that my data sources are not DataTables. I have
> > > > > > ArrayLists
> > > > > > filled with ListItems.
> > > > > > The problem is I cannot serialize this kind of ArrayLists to
> session
> > > > state
> > > > > > kept in state server.
> > > > > > > > > > Thanks,
> > > > > > Leszek
> > > > > > > > > > "Kevin Spencer" <kspencer@.takempis.com> wrote in message
> > > > > > news:uC0bhX$yEHA.336@.TK2MSFTNGP10.phx.gbl...
> > > > > >> You didn't say you wanted to serialize Controls, you said you
> > wanted
> > > to
> > > > > >> serialize the DataSource that you're binding to. A ListItem is
a
> UI
> > > > > > Control,
> > > > > >> and there's no need (or even a good reason) to serialize it.
Just
> > > store
> > > > > > the
> > > > > >> DataTable in Session and bind to it.
> > > > > >>
> > > > > >> --
> > > > > >> HTH,
> > > > > >> Kevin Spencer
> > > > > >> .Net Developer
> > > > > >> Microsoft MVP
> > > > > >> Neither a follower
> > > > > >> nor a lender be.
> > > > > >>
> > > > > >> "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > > > >> news:OAlaM5#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> > > > > >> > Thanks, but this what I have already tried. The problem is
the
> > > > ListItem
> > > > > >> > class is not serializable.
> > > > > >> > > > > >> > I have created my own ListItem-like class (serializable) and
> > copied
> > > > > >> > drop-down list data sources (using my ListItem class) to
> > > ArrayLists.
> > > > > > Then
> > > > > >> I
> > > > > >> > put the array lists into a hash table with keys as drop-down
> > lists'
> > > > > >> > ids.
> > > > > >> > This solution does not work. When I try to deserialize such a
> > > > > >> > structure,
> > > > > >> > .NET gives me an exception that the type version has been
> changed
> > > and
> > > > > >> > it
> > > > > >> is
> > > > > >> > not possible to deserialize data. I think the type is too
> complex
> > > for
> > > > > >> > serialization (custom ListItem-like objects within ArrayLists
> > > within
> > > > a
> > > > > >> > Hashtable).
> > > > > >> > > > > >> > Any other suggestions,
> > > > > >> > Leszek
> > > > > >> > > > > >> > "Kikoz" <kikoz@.hotmail.com> wrote in message
> > > > > >> > news:O14Fov#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> > > > > >> > > Use DataTable or HashTable, they are serializable.
> > > > > >> > > > > > >> > > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > > > >> > > news:%23byMha%23yEHA.2200@.TK2MSFTNGP09.phx.gbl...
> > > > > >> > > > Hello,
> > > > > >> > > > > > > >> > > > I have several drop-down lists on my ASP.NET page. I need
> to
> > > keep
> > > > > > data
> > > > > >> > > > sources of these lists in Session State.
> > > > > >> > > > What would be the most effective method to serialize this
> > kind
> > > of
> > > > > > data
> > > > > >> > > > structures?
> > > > > >> > > > > > > >> > > > Thanks for any hints,
> > > > > >> > > > Leszek Taratuta
> > > > > >> > > > > > > >> > > > > > > >> > > > > > >> > > > > > >> > > > > >> > > > > >>
> > > > > >>
> > > > > > > > > > > > > > > > > > > >
I would go with a DataTable.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Leszek Taratuta" <ads@.taratuta.net> wrote in message
news:uxFQ8ACzEHA.804@.TK2MSFTNGP12.phx.gbl...
> Thanks a lot. It seems DataTable is the best solution.
> In the meantime the database guy decided to fill ArrayLists not with
> ListItems but with some user defined structures similar to ListItems:
> public sealed class ItemData
> {
> public string name;
> public int val;
> public ItemData(string name, int val)
> {
> this.name = name;
> this.val = val;
> }
> }
> Now I need to populate drop-down lists manually using code like this:
> // list - an ArrayList containing ItemDatas
> // ddl - the drop-down list control
> for ( int i = 0; i < list.Count; i++ )
> {
> ddl.Items.Add( new ListItem( ((ItemData) list[i]).Name, ((ItemData)
> list[i]).Id.ToString() ) );
> }
> What do you think about such a solution? Is it any better than passing
> DataTable? For sure it is more cumbersome in terms of populating the
lists,
> but the database guy wants the smallest possible footprint and ItemData
> items are light (they are structures). But on the other hand they are
> elements of ArrayList that boxes the sturcture elements (that are value
> types) to have reference types.
> So my question is which option is better DataTable or the custom-defined
> ItemData elements contained in an ArrayList?
> Thanks,
> Leszek
> "Kevin Spencer" <kspencer@.takempis.com> wrote in message
> news:urNAYrBzEHA.3408@.tk2msftngp13.phx.gbl...
> > Hi Leszek,
> > First of all, as was mentioned earlier, ListItems are UI elements. A
> > well-designed Data Layer should NEVER work with UI elements. Why, even
> your
> > business layer shouldn't be working with UI elements. Only data
structures
> > should come from the Data Layer. That would be raw primitve data, such
as
> > integers, dates, and strings, DataSets, DataTables, and DataReaders.
Now,
> > there is some controversy over returning DataReaders, so the next
smallest
> > data structure (other than primitives) would be a DataTable, and it
really
> > has a relatively small footprint. DataReaders are the smallest, but have
> > some issues, such as necessitating a constant Connection while in use,
as
> > well as being forward-only, read-only, and not being serializable.
> > --
> > HTH,
> > Kevin Spencer
> > .Net Developer
> > Microsoft MVP
> > Neither a follower
> > nor a lender be.
> > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > news:OIzVpPBzEHA.2568@.TK2MSFTNGP11.phx.gbl...
> > > Thank you. I am going to talk with the guy who creates the data layer.
> > > > BTW
> > > What could be the best alternative to get drop-down list data sources
> from
> > > the data layer? DataTables are pretty heavy. Any other possibilities.
> > > > Thanks,
> > > > Leszek
> > > > "Kevin Spencer" <kspencer@.takempis.com> wrote in message
> > > news:#raiusAzEHA.1452@.TK2MSFTNGP11.phx.gbl...
> > > > Well, Leszek, it seems that the wrong person is asking this question
> of
> > > the
> > > > newsgroup. Whoever is sending you ArrayLists of ListItems is the one
> who
> > > > needs the help!
> > > > > > --
> > > > HTH,
> > > > Kevin Spencer
> > > > .Net Developer
> > > > Microsoft MVP
> > > > Neither a follower
> > > > nor a lender be.
> > > > > > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > > news:#AIc3TAzEHA.1292@.TK2MSFTNGP10.phx.gbl...
> > > > > Well, I know it is much easier to store data in serializable
object
> > like
> > > > > DataTable but I work in a team, and what I receive from the data
> layer
> > > is
> > > > > ArrayList containing ListItems.
> > > > > For now the only resonable solution is to convert the ArrayLists
to
> > > > > DataTables. It is not efficient though. I thought it would be any
> > other
> > > > more
> > > > > appropriate way to store this kind of data. Any kind of
> serialization
> > > from
> > > > > ArrayLists to strings or so, and then deserialization.
> > > > > > > > Thanks,
> > > > > Leszek
> > > > > > > > "Kikoz" <kikoz@.hotmail.com> wrote in message
> > > > > news:Obu#I3$yEHA.1292@.TK2MSFTNGP10.phx.gbl...
> > > > > > I think you complicate things for no obvious reason :) I may be
> > > totally
> > > > > > wrong, it all depends on particular situation, but this is what
it
> > > seems
> > > > > > like. Much easier to store data in serializable object like
> > DataTable
> > > > and
> > > > > > then keep it on server, even if that would require to put your
> data
> > in
> > > > > such
> > > > > > table first.
> > > > > > > > > > > > > > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > > > > news:OEVLPz$yEHA.1412@.tk2msftngp13.phx.gbl...
> > > > > > > Thanks. I forgot the ListItems are controls.
> > > > > > > The situation is that my data sources are not DataTables. I
have
> > > > > > > ArrayLists
> > > > > > > filled with ListItems.
> > > > > > > The problem is I cannot serialize this kind of ArrayLists to
> > session
> > > > > state
> > > > > > > kept in state server.
> > > > > > > > > > > > Thanks,
> > > > > > > Leszek
> > > > > > > > > > > > "Kevin Spencer" <kspencer@.takempis.com> wrote in message
> > > > > > > news:uC0bhX$yEHA.336@.TK2MSFTNGP10.phx.gbl...
> > > > > > >> You didn't say you wanted to serialize Controls, you said you
> > > wanted
> > > > to
> > > > > > >> serialize the DataSource that you're binding to. A ListItem
is
> a
> > UI
> > > > > > > Control,
> > > > > > >> and there's no need (or even a good reason) to serialize it.
> Just
> > > > store
> > > > > > > the
> > > > > > >> DataTable in Session and bind to it.
> > > > > > >>
> > > > > > >> --
> > > > > > >> HTH,
> > > > > > >> Kevin Spencer
> > > > > > >> .Net Developer
> > > > > > >> Microsoft MVP
> > > > > > >> Neither a follower
> > > > > > >> nor a lender be.
> > > > > > >>
> > > > > > >> "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > > > > >> news:OAlaM5#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> > > > > > >> > Thanks, but this what I have already tried. The problem is
> the
> > > > > ListItem
> > > > > > >> > class is not serializable.
> > > > > > >> > > > > > >> > I have created my own ListItem-like class (serializable)
and
> > > copied
> > > > > > >> > drop-down list data sources (using my ListItem class) to
> > > > ArrayLists.
> > > > > > > Then
> > > > > > >> I
> > > > > > >> > put the array lists into a hash table with keys as
drop-down
> > > lists'
> > > > > > >> > ids.
> > > > > > >> > This solution does not work. When I try to deserialize such
a
> > > > > > >> > structure,
> > > > > > >> > .NET gives me an exception that the type version has been
> > changed
> > > > and
> > > > > > >> > it
> > > > > > >> is
> > > > > > >> > not possible to deserialize data. I think the type is too
> > complex
> > > > for
> > > > > > >> > serialization (custom ListItem-like objects within
ArrayLists
> > > > within
> > > > > a
> > > > > > >> > Hashtable).
> > > > > > >> > > > > > >> > Any other suggestions,
> > > > > > >> > Leszek
> > > > > > >> > > > > > >> > "Kikoz" <kikoz@.hotmail.com> wrote in message
> > > > > > >> > news:O14Fov#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> > > > > > >> > > Use DataTable or HashTable, they are serializable.
> > > > > > >> > > > > > > >> > > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > > > > >> > > news:%23byMha%23yEHA.2200@.TK2MSFTNGP09.phx.gbl...
> > > > > > >> > > > Hello,
> > > > > > >> > > > > > > > >> > > > I have several drop-down lists on my ASP.NET page. I
need
> > to
> > > > keep
> > > > > > > data
> > > > > > >> > > > sources of these lists in Session State.
> > > > > > >> > > > What would be the most effective method to serialize
this
> > > kind
> > > > of
> > > > > > > data
> > > > > > >> > > > structures?
> > > > > > >> > > > > > > > >> > > > Thanks for any hints,
> > > > > > >> > > > Leszek Taratuta
> > > > > > >> > > > > > > > >> > > > > > > > >> > > > > > > >> > > > > > > >> > > > > > >> > > > > > >>
> > > > > > >>
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
Thanks a lot. I will use DataTables.

Leszek

"Kevin Spencer" <kspencer@.takempis.com> wrote in message
news:#9O8zoCzEHA.1524@.TK2MSFTNGP09.phx.gbl...
> I would go with a DataTable.
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Neither a follower
> nor a lender be.
> "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> news:uxFQ8ACzEHA.804@.TK2MSFTNGP12.phx.gbl...
> > Thanks a lot. It seems DataTable is the best solution.
> > In the meantime the database guy decided to fill ArrayLists not with
> > ListItems but with some user defined structures similar to ListItems:
> > public sealed class ItemData
> > {
> > public string name;
> > public int val;
> > public ItemData(string name, int val)
> > {
> > this.name = name;
> > this.val = val;
> > }
> > }
> > Now I need to populate drop-down lists manually using code like this:
> > // list - an ArrayList containing ItemDatas
> > // ddl - the drop-down list control
> > for ( int i = 0; i < list.Count; i++ )
> > {
> > ddl.Items.Add( new ListItem( ((ItemData) list[i]).Name, ((ItemData)
> > list[i]).Id.ToString() ) );
> > }
> > What do you think about such a solution? Is it any better than passing
> > DataTable? For sure it is more cumbersome in terms of populating the
> lists,
> > but the database guy wants the smallest possible footprint and ItemData
> > items are light (they are structures). But on the other hand they are
> > elements of ArrayList that boxes the sturcture elements (that are value
> > types) to have reference types.
> > So my question is which option is better DataTable or the custom-defined
> > ItemData elements contained in an ArrayList?
> > Thanks,
> > Leszek
> > "Kevin Spencer" <kspencer@.takempis.com> wrote in message
> > news:urNAYrBzEHA.3408@.tk2msftngp13.phx.gbl...
> > > Hi Leszek,
> > > > First of all, as was mentioned earlier, ListItems are UI elements. A
> > > well-designed Data Layer should NEVER work with UI elements. Why, even
> > your
> > > business layer shouldn't be working with UI elements. Only data
> structures
> > > should come from the Data Layer. That would be raw primitve data, such
> as
> > > integers, dates, and strings, DataSets, DataTables, and DataReaders.
> Now,
> > > there is some controversy over returning DataReaders, so the next
> smallest
> > > data structure (other than primitives) would be a DataTable, and it
> really
> > > has a relatively small footprint. DataReaders are the smallest, but
have
> > > some issues, such as necessitating a constant Connection while in use,
> as
> > > well as being forward-only, read-only, and not being serializable.
> > > > --
> > > HTH,
> > > Kevin Spencer
> > > .Net Developer
> > > Microsoft MVP
> > > Neither a follower
> > > nor a lender be.
> > > > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > news:OIzVpPBzEHA.2568@.TK2MSFTNGP11.phx.gbl...
> > > > Thank you. I am going to talk with the guy who creates the data
layer.
> > > > > > BTW
> > > > What could be the best alternative to get drop-down list data
sources
> > from
> > > > the data layer? DataTables are pretty heavy. Any other
possibilities.
> > > > > > Thanks,
> > > > > > Leszek
> > > > > > "Kevin Spencer" <kspencer@.takempis.com> wrote in message
> > > > news:#raiusAzEHA.1452@.TK2MSFTNGP11.phx.gbl...
> > > > > Well, Leszek, it seems that the wrong person is asking this
question
> > of
> > > > the
> > > > > newsgroup. Whoever is sending you ArrayLists of ListItems is the
one
> > who
> > > > > needs the help!
> > > > > > > > --
> > > > > HTH,
> > > > > Kevin Spencer
> > > > > .Net Developer
> > > > > Microsoft MVP
> > > > > Neither a follower
> > > > > nor a lender be.
> > > > > > > > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > > > news:#AIc3TAzEHA.1292@.TK2MSFTNGP10.phx.gbl...
> > > > > > Well, I know it is much easier to store data in serializable
> object
> > > like
> > > > > > DataTable but I work in a team, and what I receive from the data
> > layer
> > > > is
> > > > > > ArrayList containing ListItems.
> > > > > > For now the only resonable solution is to convert the ArrayLists
> to
> > > > > > DataTables. It is not efficient though. I thought it would be
any
> > > other
> > > > > more
> > > > > > appropriate way to store this kind of data. Any kind of
> > serialization
> > > > from
> > > > > > ArrayLists to strings or so, and then deserialization.
> > > > > > > > > > Thanks,
> > > > > > Leszek
> > > > > > > > > > "Kikoz" <kikoz@.hotmail.com> wrote in message
> > > > > > news:Obu#I3$yEHA.1292@.TK2MSFTNGP10.phx.gbl...
> > > > > > > I think you complicate things for no obvious reason :) I may
be
> > > > totally
> > > > > > > wrong, it all depends on particular situation, but this is
what
> it
> > > > seems
> > > > > > > like. Much easier to store data in serializable object like
> > > DataTable
> > > > > and
> > > > > > > then keep it on server, even if that would require to put your
> > data
> > > in
> > > > > > such
> > > > > > > table first.
> > > > > > > > > > > > > > > > > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > > > > > news:OEVLPz$yEHA.1412@.tk2msftngp13.phx.gbl...
> > > > > > > > Thanks. I forgot the ListItems are controls.
> > > > > > > > The situation is that my data sources are not DataTables. I
> have
> > > > > > > > ArrayLists
> > > > > > > > filled with ListItems.
> > > > > > > > The problem is I cannot serialize this kind of ArrayLists to
> > > session
> > > > > > state
> > > > > > > > kept in state server.
> > > > > > > > > > > > > > Thanks,
> > > > > > > > Leszek
> > > > > > > > > > > > > > "Kevin Spencer" <kspencer@.takempis.com> wrote in message
> > > > > > > > news:uC0bhX$yEHA.336@.TK2MSFTNGP10.phx.gbl...
> > > > > > > >> You didn't say you wanted to serialize Controls, you said
you
> > > > wanted
> > > > > to
> > > > > > > >> serialize the DataSource that you're binding to. A ListItem
> is
> > a
> > > UI
> > > > > > > > Control,
> > > > > > > >> and there's no need (or even a good reason) to serialize
it.
> > Just
> > > > > store
> > > > > > > > the
> > > > > > > >> DataTable in Session and bind to it.
> > > > > > > >>
> > > > > > > >> --
> > > > > > > >> HTH,
> > > > > > > >> Kevin Spencer
> > > > > > > >> .Net Developer
> > > > > > > >> Microsoft MVP
> > > > > > > >> Neither a follower
> > > > > > > >> nor a lender be.
> > > > > > > >>
> > > > > > > >> "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > > > > > >> news:OAlaM5#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> > > > > > > >> > Thanks, but this what I have already tried. The problem
is
> > the
> > > > > > ListItem
> > > > > > > >> > class is not serializable.
> > > > > > > >> > > > > > > >> > I have created my own ListItem-like class (serializable)
> and
> > > > copied
> > > > > > > >> > drop-down list data sources (using my ListItem class) to
> > > > > ArrayLists.
> > > > > > > > Then
> > > > > > > >> I
> > > > > > > >> > put the array lists into a hash table with keys as
> drop-down
> > > > lists'
> > > > > > > >> > ids.
> > > > > > > >> > This solution does not work. When I try to deserialize
such
> a
> > > > > > > >> > structure,
> > > > > > > >> > .NET gives me an exception that the type version has been
> > > changed
> > > > > and
> > > > > > > >> > it
> > > > > > > >> is
> > > > > > > >> > not possible to deserialize data. I think the type is too
> > > complex
> > > > > for
> > > > > > > >> > serialization (custom ListItem-like objects within
> ArrayLists
> > > > > within
> > > > > > a
> > > > > > > >> > Hashtable).
> > > > > > > >> > > > > > > >> > Any other suggestions,
> > > > > > > >> > Leszek
> > > > > > > >> > > > > > > >> > "Kikoz" <kikoz@.hotmail.com> wrote in message
> > > > > > > >> > news:O14Fov#yEHA.4044@.TK2MSFTNGP10.phx.gbl...
> > > > > > > >> > > Use DataTable or HashTable, they are serializable.
> > > > > > > >> > > > > > > > >> > > "Leszek Taratuta" <ads@.taratuta.net> wrote in message
> > > > > > > >> > > news:%23byMha%23yEHA.2200@.TK2MSFTNGP09.phx.gbl...
> > > > > > > >> > > > Hello,
> > > > > > > >> > > > > > > > > >> > > > I have several drop-down lists on my ASP.NET page. I
> need
> > > to
> > > > > keep
> > > > > > > > data
> > > > > > > >> > > > sources of these lists in Session State.
> > > > > > > >> > > > What would be the most effective method to serialize
> this
> > > > kind
> > > > > of
> > > > > > > > data
> > > > > > > >> > > > structures?
> > > > > > > >> > > > > > > > > >> > > > Thanks for any hints,
> > > > > > > >> > > > Leszek Taratuta
> > > > > > > >> > > > > > > > > >> > > > > > > > > >> > > > > > > > >> > > > > > > > >> > > > > > > >> > > > > > > >>
> > > > > > > >>
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >