Refer -
Pushing a Geneic List of <t> to View state[
^].
Quote:
Here's another quick way if you just wanted to Save things to the view state:
- Mark the Class (and all parent classes if any) whose List you want to store in the
ViewState
as [Serializable]. - Convert the
List
to an Array
. - Store in
ViewState
.
But the
ListItem
you have used is not
Serializable
.
So, create your own class with public key/value properties, mark it
Serializable
and convert to
Array
and store in
ViewState
(as described in that link for
Customer
Class).
Note
Store List in
ViewState
if you have less number of Data in List.