|
Hi, I'm facing problem when i load page with dynamically created controls. This happens if i save a arraylist in viewstate. ViewState["Delim"] = arrList; I searched the net, and found that we can save arraylists in viewstate, and that try saving it in page_preRender. I did so, but same issue. If i save some string in viewstate instead, it doesn't have any problems loading the dynamic controls.
Anyone can help me here, to resolve this?
Thanks, Deepa
| | |
deepaPosted Aug 17, 2009, 5:51 AM
it worked
Shakeel IqbalPosted Aug 17, 2009, 3:52 AM
Add serializable attribute on your class.
e.g
[Serializable]
public class MyClass
{
......
......
......
}
Solution#2
if your class has complex object. then inherit your class from System.Xml.Serialization.IXmlSerializable and override its methods.
deepaPosted Aug 17, 2009, 3:12 AM
The arraylist contains objects of a particular class. Is it a problem?
If i save some string in the arraylist then it does not give any problem. Is it to do with object in arraylist?
I dont get it...it goes to the Application_Error event in global.asax.cs.
The class is a non serializable class.
How do i resolve this? i need to store the arraylist in viewstate, because i require it on one button click event.
Shakeel IqbalPosted Aug 17, 2009, 2:22 AM
You can not save control/object in ArrayList, which are not serializable. if you are saving your own object in ArrayList then inherit your class from ISerializable interface.