you need to make your clase with Serializble attribute.
Here I write an example
This is my class "Persona"
[Serializable]
public class Persona
{
public string nombre;
}
This may be in page load ...
if (!IsPostBack)
{
ArrayList array = new ArrayList(2);
Persona objPer = new Persona();
objPer.nombre = "Ricky";
array.Add(objPer);
objPer = new Persona();
objPer.nombre = "Ricky 2";
array.Add(objPer);
ViewState["Persona"] = array;
}
else
{
ArrayList array = (ArrayList)ViewState["Persona"];
for(int i = 0; i < array.Count; i++)
Response.Write(((Persona)array[i]).nombre);
}
This code will write the name saved in the ViewState after PostBack
Hope this helps
Bye
Ricky
Ricardo D. de Guzmán
Tercer Planeta