Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Preserving state for ArrayList
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00934719
Message ID:
00934967
Views:
15
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
Previous
Reply
Map
View

Click here to load this message in the networking platform