Click here to Skip to main content
16,019,087 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi to all
how can i put a list of list item into a view state
my code

C#
List<ListItem> extraWorkOperations = new List<ListItem>();
ViewState["extraWorkOperations "]=extraWorkOperations ;

thanks in advance
Posted

1 solution

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:


  1. Mark the Class (and all parent classes if any) whose List you want to store in the ViewState as [Serializable].
  2. Convert the List to an Array.
  3. 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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900