In my EntityCollectio n inherted from CollectionBase I marked it
[Serializable] and Implement ISerializable Interface..
here is the code..
GetObjectDate( .....)
info.AddValue(" Col",this.Inner List,typeof(Arr ayList));
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(ArrayLi st));
this.InsertRang e(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 EntityCollectio n();
ent.Add(Entity. CreateInstance( "ID1",Name) );
ent.Add(Entity. CreateInstance( "ID2",Name) );
ent.Add(Entity. CreateInstance( "ID3",Name) );
Datagrid1.DataS ource = ent;
Datagrid1.Datab ind();
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 = (EntityCollecti on)ViewState["coll"];
ent.Add(Entity. CreateInstance( "ID3",Name) );
Datagrid1.Datab ind();
}
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?? 4 1482
Well, forst of all if the DataGrid is ViewState enabled, there is no need to
add the Collection it is bound to to ViewState. The DataGrid contents are
saved in ViewState already.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
"Islamegy®" <Is******@Priva te.4me> wrote in message
news:OX******** ******@TK2MSFTN GP14.phx.gbl... In my EntityCollectio n inherted from CollectionBase I marked it [Serializable] and Implement ISerializable Interface.. here is the code.. GetObjectDate( .....) info.AddValue(" Col",this.Inner List,typeof(Arr ayList));
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(ArrayLi st)); this.InsertRang e(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 EntityCollectio n(); ent.Add(Entity. CreateInstance( "ID1",Name) ); ent.Add(Entity. CreateInstance( "ID2",Name) ); ent.Add(Entity. CreateInstance( "ID3",Name) ); Datagrid1.DataS ource = ent; Datagrid1.Datab ind(); 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 = (EntityCollecti on)ViewState["coll"]; ent.Add(Entity. CreateInstance( "ID3",Name) ); Datagrid1.Datab ind(); } 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??
My Datagrid is Viwstate enabled and if the selection changeed i have no
problems and collection is there but when i add or remove from the
collection i loose it..
"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:Og******** ******@tk2msftn gp13.phx.gbl... Well, forst of all if the DataGrid is ViewState enabled, there is no need to add the Collection it is bound to to ViewState. The DataGrid contents are saved in ViewState already.
-- HTH,
Kevin Spencer Microsoft MVP .Net Developer Ambiguity has a certain quality to it.
"Islamegy®" <Is******@Priva te.4me> wrote in message news:OX******** ******@TK2MSFTN GP14.phx.gbl... In my EntityCollectio n inherted from CollectionBase I marked it [Serializable] and Implement ISerializable Interface.. here is the code.. GetObjectDate( .....) info.AddValue(" Col",this.Inner List,typeof(Arr ayList));
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(ArrayLi st)); this.InsertRang e(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 EntityCollectio n(); ent.Add(Entity. CreateInstance( "ID1",Name) ); ent.Add(Entity. CreateInstance( "ID2",Name) ); ent.Add(Entity. CreateInstance( "ID3",Name) ); Datagrid1.DataS ource = ent; Datagrid1.Datab ind(); 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 = (EntityCollecti on)ViewState["coll"]; ent.Add(Entity. CreateInstance( "ID3",Name) ); Datagrid1.Datab ind(); } 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??
In that case, you shouldn't need to DataBind again. It is already bound to
the DataGrid.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
"Islamegy®" <Is******@Priva te.4me> wrote in message
news:u1******** ******@tk2msftn gp13.phx.gbl... My Datagrid is Viwstate enabled and if the selection changeed i have no problems and collection is there but when i add or remove from the collection i loose it.. "Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message news:Og******** ******@tk2msftn gp13.phx.gbl... Well, forst of all if the DataGrid is ViewState enabled, there is no need to add the Collection it is bound to to ViewState. The DataGrid contents are saved in ViewState already.
-- HTH,
Kevin Spencer Microsoft MVP .Net Developer Ambiguity has a certain quality to it.
"Islamegy®" <Is******@Priva te.4me> wrote in message news:OX******** ******@TK2MSFTN GP14.phx.gbl... In my EntityCollectio n inherted from CollectionBase I marked it [Serializable] and Implement ISerializable Interface.. here is the code.. GetObjectDate( .....) info.AddValue(" Col",this.Inner List,typeof(Arr ayList));
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(ArrayLi st)); this.InsertRang e(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 EntityCollectio n(); ent.Add(Entity. CreateInstance( "ID1",Name) ); ent.Add(Entity. CreateInstance( "ID2",Name) ); ent.Add(Entity. CreateInstance( "ID3",Name) ); Datagrid1.DataS ource = ent; Datagrid1.Datab ind(); 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 = (EntityCollecti on)ViewState["coll"]; ent.Add(Entity. CreateInstance( "ID3",Name) ); Datagrid1.Datab ind(); } 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??
I hope yuo'll forgive me, but I don't have time to look thorough all that
code.
This sort of problem is usually associated with a sequence issue. ASP.Net
Controls, including, and perhaps most importantly, System.Web.UI.P age, have
a sequence of execution. Certain events fire in a certain sequence, and it's
important to make sure that you put your code in the right place in the
sequence, that is, in the right event handler. The following is a link to an
MSDN .Net Libary article that explains the "Execution Lifecycle" of ASP.Net
Controls. I keep a copy taped to my office wall! http://msdn.microsoft.com/library/de...nLifecycle.asp
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
"Islamegy®" <Is******@Priva te.4me> wrote in message
news:uY******** ******@TK2MSFTN GP12.phx.gbl... Ok.. that's dosn't make diffrent.. In this way the data is there in the grid but When i add new entity i don't find it?? Do u tell me what's wrong i do?? I attached my files so u code tell me what's wrong i do, Why i can't add new entity??
"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message news:ed******** ******@TK2MSFTN GP10.phx.gbl... In that case, you shouldn't need to DataBind again. It is already bound to the DataGrid.
-- HTH,
Kevin Spencer Microsoft MVP .Net Developer Ambiguity has a certain quality to it.
"Islamegy®" <Is******@Priva te.4me> wrote in message news:u1******** ******@tk2msftn gp13.phx.gbl... My Datagrid is Viwstate enabled and if the selection changeed i have no problems and collection is there but when i add or remove from the collection i loose it.. "Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message news:Og******** ******@tk2msftn gp13.phx.gbl... Well, forst of all if the DataGrid is ViewState enabled, there is no need to add the Collection it is bound to to ViewState. The DataGrid contents are saved in ViewState already.
-- HTH,
Kevin Spencer Microsoft MVP .Net Developer Ambiguity has a certain quality to it.
"Islamegy®" <Is******@Priva te.4me> wrote in message news:OX******** ******@TK2MSFTN GP14.phx.gbl... > In my EntityCollectio n inherted from CollectionBase I marked it > [Serializable] and Implement ISerializable Interface.. > here is the code.. > GetObjectDate( .....) > info.AddValue(" Col",this.Inner List,typeof(Arr ayList)); > > 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(ArrayLi st)); > this.InsertRang e(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 EntityCollectio n(); > ent.Add(Entity. CreateInstance( "ID1",Name) ); > ent.Add(Entity. CreateInstance( "ID2",Name) ); > ent.Add(Entity. CreateInstance( "ID3",Name) ); > Datagrid1.DataS ource = ent; > Datagrid1.Datab ind(); > 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 = (EntityCollecti on)ViewState["coll"]; > ent.Add(Entity. CreateInstance( "ID3",Name) ); > Datagrid1.Datab ind(); > } > 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?? > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Lars-Erik Aabech |
last post by:
Hi!
I've got problems with serializing my collections of business objects. The
objects themselves serialize fine, but the collections fail. I've got the
following structure:
Base collection class:
Derives MarshalByValueComponent
Implements ICollection, IList and ISerializable
Explicitly implements the IList methods as private members, (ie. int
|
by: vince |
last post by:
Can I add (append) to an xml file that already contains a
serialized object, and be able to deserialize to either
or both objects from the same file...??? How is this
done...??
thanks,
vince
|
by: films |
last post by:
I understand the concept.
Serialization of a class will add all the sub-objects of the class to
the stream if there are also serializible.
So say I have:
class Author
{
|
by: Gislain |
last post by:
Hello,
I'm looking for a best way to serialize multiple / different object in the
same XML file, and of course, how can i deserialize it.
Actualy, when i serialize the first object in XML file, it work fine,
But the second erase the entry of the first object !!!
Thank's by advance
|
by: Jinsong Liu |
last post by:
I have following 3 classes
public class MyMainClass
{
MyCollection<MyObject> m_oMyObjectCollection = null;
private string m_sID = string.Empty;
public MyCollection<MyObject> Collection
{
| |
by: Joe |
last post by:
If I create a simple collection with say 20 columns and 5000 row and a
DataTable with the same and serialize both, the DataTable file is at least 2
times the size as the simple collection. What is all the overhead with the
DataTable?
-Joe
|
by: Sugandh Jain |
last post by:
I am using a method to serialize objects to xml.
this method is working fine to serialize most of the objects to Xml.
For one collection object, it is not doing so. The Collection and its
containing object are marked .
What could be the reasons for the object not getting serialize, and this is
what i get.
<?xml version="1.0"?>
|
by: Dmitry Nogin |
last post by:
Hi,
Is it possible to xml-serialize an heterogenous collection? I mean the
situation when class B inherits class A, and I'd like to serialize (to
application settings) my BindingList<Acollection, which references some
objects of A and B types.
thanks in advance.
-- dmitry
|
by: =?Utf-8?B?U2hhd24=?= |
last post by:
Hi;
I would like to be able to use the XMLSerializer to serialize and
deserialize a dictionary. is that possible? i know that you can serialize an
object that implements the ICollection interface. does the fact that
Dictionary inherits from ICollection<cause a problem?
Currently i am using a class that inherits from ICollection and it has a
Dictionary as it's container. but when it gets to creating the serialized
object it blows up. here...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |