【发布时间】:2014-11-22 06:47:28
【问题描述】:
我正在存储List<KeyValuePair<string, bool>> 的集合
在 ViewState 中,当我尝试将其转换回 List<KeyValuePair<string, bool>> 时会出现问题
错误状态
无法转换类型为“System.Collections.Generic.Dictionary
2[System.String,System.Boolean]' to type 'System.Collections.Generic.List1[System.Collections.Generic.KeyValuePair`2[System.String,System.Boolean]]”的对象。
那么如何将我的键值列表从 ViewState 转换回来?
我的代码行是:
List<KeyValuePair<string, bool>> myObject = (List<KeyValuePair<string, bool>>)ViewState["listOutputWords"];
【问题讨论】:
-
请粘贴您尝试过的代码??
-
List
> myObject = (List >)ViewState["listOutputWords"]; -
您在
ViewState["listOutputWords"]中输入了什么?同时显示完整的异常数据。 -
我添加了完整的例外
-
我认为您将
KeyValuePair<string, bool>保存在ViewState["listOutputWords"]中
标签: c# asp.net .net collections viewstate