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 13 5128
Use DataTable or HashTable, they are serializable.
"Leszek Taratuta" <ad*@taratuta.net> wrote in message
news:%2******************@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" <ki***@hotmail.com> wrote in message
news:O1**************@TK2MSFTNGP10.phx.gbl... Use DataTable or HashTable, they are serializable.
"Leszek Taratuta" <ad*@taratuta.net> wrote in message news:%2******************@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" <ad*@taratuta.net> wrote in message
news:OA**************@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" <ki***@hotmail.com> wrote in message news:O1**************@TK2MSFTNGP10.phx.gbl... Use DataTable or HashTable, they are serializable.
"Leszek Taratuta" <ad*@taratuta.net> wrote in message news:%2******************@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" <ad*@taratuta.net> wrote in message
news:OA****************@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" <ki***@hotmail.com> wrote in message news:O1**************@TK2MSFTNGP10.phx.gbl... Use DataTable or HashTable, they are serializable.
"Leszek Taratuta" <ad*@taratuta.net> wrote in message news:%2******************@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" <ks******@takempis.com> wrote in message
news:uC*************@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" <ad*@taratuta.net> wrote in message news:OA**************@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" <ki***@hotmail.com> wrote in message news:O1**************@TK2MSFTNGP10.phx.gbl... Use DataTable or HashTable, they are serializable.
"Leszek Taratuta" <ad*@taratuta.net> wrote in message news:%2******************@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" <ad*@taratuta.net> wrote in message
news:OE**************@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" <ks******@takempis.com> wrote in message news:uC*************@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" <ad*@taratuta.net> wrote in message news:OA**************@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" <ki***@hotmail.com> wrote in message > news:O1**************@TK2MSFTNGP10.phx.gbl... > > Use DataTable or HashTable, they are serializable. > > > > "Leszek Taratuta" <ad*@taratuta.net> wrote in message > > news:%2******************@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" <ki***@hotmail.com> wrote in message
news:Ob**************@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" <ad*@taratuta.net> wrote in message news:OE**************@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" <ks******@takempis.com> wrote in message news:uC*************@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" <ad*@taratuta.net> wrote in message news:OA**************@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" <ki***@hotmail.com> wrote in message > news:O1**************@TK2MSFTNGP10.phx.gbl... > > Use DataTable or HashTable, they are serializable. > > > > "Leszek Taratuta" <ad*@taratuta.net> wrote in message > > news:%2******************@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" <ad*@taratuta.net> wrote in message
news:#A**************@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" <ki***@hotmail.com> wrote in message news:Ob**************@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" <ad*@taratuta.net> wrote in message news:OE**************@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" <ks******@takempis.com> wrote in message news:uC*************@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" <ad*@taratuta.net> wrote in message > news:OA**************@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" <ki***@hotmail.com> wrote in message > > news:O1**************@TK2MSFTNGP10.phx.gbl... > > > Use DataTable or HashTable, they are serializable. > > > > > > "Leszek Taratuta" <ad*@taratuta.net> wrote in message > > > news:%2******************@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" <ks******@takempis.com> wrote in message
news:#r**************@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" <ad*@taratuta.net> wrote in message news:#A**************@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" <ki***@hotmail.com> wrote in message news:Ob**************@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" <ad*@taratuta.net> wrote in message news:OE**************@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" <ks******@takempis.com> wrote in message > news:uC*************@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" <ad*@taratuta.net> wrote in message >> news:OA**************@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" <ki***@hotmail.com> wrote in message >> > news:O1**************@TK2MSFTNGP10.phx.gbl... >> > > Use DataTable or HashTable, they are serializable. >> > > >> > > "Leszek Taratuta" <ad*@taratuta.net> wrote in message >> > > news:%2******************@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" <ad*@taratuta.net> wrote in message
news:OI**************@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" <ks******@takempis.com> wrote in message news:#r**************@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" <ad*@taratuta.net> wrote in message news:#A**************@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" <ki***@hotmail.com> wrote in message news:Ob**************@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" <ad*@taratuta.net> wrote in message > news:OE**************@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" <ks******@takempis.com> wrote in message > > news:uC*************@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" <ad*@taratuta.net> wrote in message > >> news:OA**************@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" <ki***@hotmail.com> wrote in message > >> > news:O1**************@TK2MSFTNGP10.phx.gbl... > >> > > Use DataTable or HashTable, they are serializable. > >> > > > >> > > "Leszek Taratuta" <ad*@taratuta.net> wrote in message > >> > > news:%2******************@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" <ks******@takempis.com> wrote in message
news:ur**************@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" <ad*@taratuta.net> wrote in message news:OI**************@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" <ks******@takempis.com> wrote in message news:#r**************@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" <ad*@taratuta.net> wrote in message news:#A**************@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" <ki***@hotmail.com> wrote in message > news:Ob**************@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" <ad*@taratuta.net> wrote in message > > news:OE**************@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" <ks******@takempis.com> wrote in message > > > news:uC*************@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" <ad*@taratuta.net> wrote in message > > >> news:OA**************@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" <ki***@hotmail.com> wrote in message > > >> > news:O1**************@TK2MSFTNGP10.phx.gbl... > > >> > > Use DataTable or HashTable, they are serializable. > > >> > > > > >> > > "Leszek Taratuta" <ad*@taratuta.net> wrote in message > > >> > > news:%2******************@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" <ad*@taratuta.net> wrote in message
news:ux*************@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" <ks******@takempis.com> wrote in message news:ur**************@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" <ad*@taratuta.net> wrote in message news:OI**************@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" <ks******@takempis.com> wrote in message news:#r**************@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" <ad*@taratuta.net> wrote in message > news:#A**************@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" <ki***@hotmail.com> wrote in message > > news:Ob**************@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" <ad*@taratuta.net> wrote in message > > > news:OE**************@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" <ks******@takempis.com> wrote in message > > > > news:uC*************@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" <ad*@taratuta.net> wrote in message > > > >> news:OA**************@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" <ki***@hotmail.com> wrote in message > > > >> > news:O1**************@TK2MSFTNGP10.phx.gbl... > > > >> > > Use DataTable or HashTable, they are serializable. > > > >> > > > > > >> > > "Leszek Taratuta" <ad*@taratuta.net> wrote in message > > > >> > > news:%2******************@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" <ks******@takempis.com> wrote in message
news:#9**************@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" <ad*@taratuta.net> wrote in message news:ux*************@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" <ks******@takempis.com> wrote in message news:ur**************@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" <ad*@taratuta.net> wrote in message news:OI**************@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" <ks******@takempis.com> wrote in message > news:#r**************@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" <ad*@taratuta.net> wrote in message > > news:#A**************@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" <ki***@hotmail.com> wrote in message > > > news:Ob**************@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" <ad*@taratuta.net> wrote in message > > > > news:OE**************@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" <ks******@takempis.com> wrote in message > > > > > news:uC*************@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" <ad*@taratuta.net> wrote in message > > > > >> news:OA**************@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" <ki***@hotmail.com> wrote in message > > > > >> > news:O1**************@TK2MSFTNGP10.phx.gbl... > > > > >> > > Use DataTable or HashTable, they are serializable. > > > > >> > > > > > > >> > > "Leszek Taratuta" <ad*@taratuta.net> wrote in message > > > > >> > > news:%2******************@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 > > > > >> > > > > > > > >> > > > > > > > >> > > > > > > >> > > > > > > >> > > > > > >> > > > > > >> > > > > >> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ante Smolcic |
last post by:
Hi all,
I have an ArrayList that contains items of type A. I declared the
XmlArrayItem atribute for that type.
Now I have an derived type B (from A) also contained in the ArrayList
but I get...
|
by: Ivo Bronsveld |
last post by:
All,
I have quite a challenging task ahead of me. I need to write an object model
(for code access) based on a schema, which cannot be made into a dataset
because of it's complexity.
So I...
|
by: Earl Teigrob |
last post by:
I am saving and restoring value types such as Int32, DateTime and Boolean in
strings. I was wondering if there is a mechanism build into .NET for
serializing and deserializing these to string...
|
by: Derrick |
last post by:
Hello all;
I seem to be having some trouble serializing a class to XML. This code is a
cut & paste from a project which used it perfectly, but all of a sudden I'm
getting an error that the "dll...
|
by: Jason Shohet |
last post by:
We are thinking of serializing an object & passing it toseveral functions on
web service.
This will happen about 35 times as the page loads. The class has about 20
attributes.
We're not sure...
|
by: mookid8000 |
last post by:
Good day group!
I have created a nice filtering plugin system, where all filters derive
from a Filter class, and they pass a PictureData object between them.
I have a problem though. I am able...
|
by: Charles Law |
last post by:
I have a complex object that I am serializing, and I would like to omit
elements that have a default value.
For example, if I have a class as follows
Public Class Test
Private m_Name As...
|
by: Kurious Oranj |
last post by:
I've currently got a database structure which is something like:-
class a
- member type
- effective date
and:-
class b
- client name
|
by: fjlaga |
last post by:
I have written an Office Add-in for Excel using VB.NET and the .NET
1.1 Framework (I have Visual Studio 2003 .NET ). All works great. I
want to add a User Settings/Prefereneces dialog and allow...
|
by: falcon198198 |
last post by:
Greetings:
I was hoping for some advice on an application. Here is what I am
working on:
Basically I have a bigger application that is having a printing
problem making multiple copies of a pdf...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |