I have following LINQ statement:
string[] str = { "a", "ab", "abcd" };
var s1 = from s in str.AsEnumerable()
select s;
ViewState.Add("str", s1);
I added s1
into ViewState
and I got following error:
Type 'System.Linq.Enumerable+WhereSelectArrayIterator`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' in Assembly 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.
How can I solve this problem and how can I add the LINQ variable into ViewState
?