Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Preserving state for ArrayList
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00934719
Message ID:
00934967
Vues:
17
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform