How to Store Generic List Value in Session object

When we are trying to store generic list value in ViewState there is always error prompt coming with some serialization problem with ViewState i.e the data stored in generic list are not well serialized and we are trying to store it in ViewState without serialized way,so in that case we need serialized it first then we can store.

So my friend follow below steps:

Step 1: You can write:

  1. List<ClassName> genericListObject = new List<MYFileInfo>();  
  2. ViewState["NameOfViewState"]= genericListObject;  

Step 2: Define class which you are mentioning in List:

  1. [Serializable]  
  2. public class ClassName  
  3. {  
  4.     function\variable  
  5. }