在会话状态中序列化下拉列表数据源 [英] Serializing drop-down list data sources in Session State

查看:66
本文介绍了在会话状态中序列化下拉列表数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我的ASP.NET页面上有几个下拉列表。我需要在会话状态下保存数据

这些列表的来源。

序列化此类数据的最有效方法是什么?
结构?


感谢任何提示,

Leszek Taratuta

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

推荐答案

使用DataTable或HashTable,它们是可序列化的。


" Leszek Taratuta" < ad*@taratuta.net>在消息中写道

新闻:%2 ****************** @ TK2MSFTNGP09.phx.gbl ...
Use DataTable or HashTable, they are serializable.

"Leszek Taratuta" <ad*@taratuta.net> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
您好,

我的ASP.NET页面上有几个下拉列表。我需要在会话状态中保存这些列表的数据源。
序列化这种数据结构的最有效方法是什么?

感谢任何提示,
Leszek Taratuta
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



谢谢,但这是我已经尝试过的。问题是ListItem

类不可序列化。


我创建了自己类似ListItem的类(可序列化)并复制了

下拉列表数据源(使用我的ListItem类)到ArrayLists。然后我将
将数组列表放入哈希表中,其中键为下拉列表''ID。

此解决方案不起作用。当我尝试反序列化这样的结构时,

..NET给了我一个例外,即类型版本已被更改,并且

无法反序列化数据。我认为类型太复杂了

序列化(在
Hashtable中的ArrayLists中自定义类似ListItem的对象)。


任何其他建议,

Leszek


" Kikoz" <き*** @ hotmail.com>在消息中写道

news:O1 ************** @ 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...
使用DataTable或HashTable,它们是可序列化的。

Leszek Taratuta < ad*@taratuta.net>在消息中写道
新闻:%2 ****************** @ TK2MSFTNGP09.phx.gbl ...
Use DataTable or HashTable, they are serializable.

"Leszek Taratuta" <ad*@taratuta.net> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
你好,

我的ASP.NET页面上有几个下拉列表。我需要在会话状态中保存这些列表的数据源。
序列化这种数据结构的最有效方法是什么?

感谢任何提示,
Leszek Taratuta
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




你没有说你想序列化控件,你说你想要

序列化你绑定的DataSource。 ListItem是一个UI控件,

并且没有必要(甚至是一个很好的理由)来序列化它。只需在会话中存储

DataTable并绑定到它。


-

HTH,

Kevin Spencer

..Net开发人员

Microsoft MVP

跟随者既不是b $ b也不是贷款人。


" Leszek Taratuta" < ad*@taratuta.net>在留言中写道

新闻:OA ************** @ 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...
谢谢,但这是什么我已经尝试过了。问题是ListItem
类不可序列化。

我创建了自己的ListItem类(可序列化)并复制了
下拉列表数据源(使用我的ListItem class)到ArrayLists。然后
我将数组列表放入一个哈希表,其中键作为下拉列表''ID。
此解决方案不起作用。当我尝试反序列化这样的结构时,.NET给了我一个例外,即类型版本已被更改,并且
无法反序列化数据。我认为类型对于序列化过于复杂(在哈希表中的ArrayLists中自定义类似ListItem的对象)。

任何其他建议,
Leszek
Kikoz <き*** @ hotmail.com>在消息中写道
新闻:O1 ************** @ 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...
使用DataTable或HashTable,它们是可序列化的。

Leszek Taratuta < ad*@taratuta.net>在消息中写道
新闻:%2 ****************** @ TK2MSFTNGP09.phx.gbl ...
Use DataTable or HashTable, they are serializable.

"Leszek Taratuta" <ad*@taratuta.net> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
你好,

我的ASP.NET页面上有几个下拉列表。我需要在会话状态中保存这些列表的数据源。
序列化这种数据结构的最有效方法是什么?

感谢任何提示,
Leszek Taratuta
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





这篇关于在会话状态中序列化下拉列表数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆