I
Islamegy®
In my EntityCollection inherted from CollectionBase I marked it
[Serializable] and Implement ISerializable Interface..
here is the code..
GetObjectDate( .....)
info.AddValue("Col",this.InnerList,typeof(ArrayList));
and while the InnerList is read only so i found some codes to workaround
using reflection.. but i didn't work so i tried to Add it using this in the
protected Constractor
{
ArrayList arr = (ArrayList)info.GetValue("Col",typeof(ArrayList));
this.InsertRange(arr);
}
the Add methodd which is needed for serialization is also there...
List.Add(entity)
but When i add this to my page viewstate and retive it back using this code
in Page_Load
{
if(!IsPostBack)
ent = new EntityCollection();
ent.Add(Entity.CreateInstance("ID1",Name));
ent.Add(Entity.CreateInstance("ID2",Name));
ent.Add(Entity.CreateInstance("ID3",Name));
Datagrid1.DataSource = ent;
Datagrid1.Databind();
ViewState.Add("coll",ent);
}
till this point there is No problems i get my collection displayed in the
grid
when i add or delete any item
{
ent = (EntityCollection)ViewState["coll"];
ent.Add(Entity.CreateInstance("ID3",Name));
Datagrid1.Databind();
}
my collection disapear even it i removed the if(!IsPostBack) or moved it to
Page_Init i will find only the original records not the one i added later so
what am i miss here??
[Serializable] and Implement ISerializable Interface..
here is the code..
GetObjectDate( .....)
info.AddValue("Col",this.InnerList,typeof(ArrayList));
and while the InnerList is read only so i found some codes to workaround
using reflection.. but i didn't work so i tried to Add it using this in the
protected Constractor
{
ArrayList arr = (ArrayList)info.GetValue("Col",typeof(ArrayList));
this.InsertRange(arr);
}
the Add methodd which is needed for serialization is also there...
List.Add(entity)
but When i add this to my page viewstate and retive it back using this code
in Page_Load
{
if(!IsPostBack)
ent = new EntityCollection();
ent.Add(Entity.CreateInstance("ID1",Name));
ent.Add(Entity.CreateInstance("ID2",Name));
ent.Add(Entity.CreateInstance("ID3",Name));
Datagrid1.DataSource = ent;
Datagrid1.Databind();
ViewState.Add("coll",ent);
}
till this point there is No problems i get my collection displayed in the
grid
when i add or delete any item
{
ent = (EntityCollection)ViewState["coll"];
ent.Add(Entity.CreateInstance("ID3",Name));
Datagrid1.Databind();
}
my collection disapear even it i removed the if(!IsPostBack) or moved it to
Page_Init i will find only the original records not the one i added later so
what am i miss here??