Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1445
Saving SortedColumnInfoCollection to Session using SessionState mode = "SQLServer"
posted

I am trying to add Session State to my app. I want to store session in SQL. One item that is being saved to session is the webdatagrid sorting information.  When I attempt to serialize my object right before sending it to session I get this error:

Type 'Infragistics.Web.UI.GridControls.SortedColumnInfoCollection' in Assembly 'Infragistics4.Web.v13.1, Version=13.1.20131.1012, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb' is not marked as serializable.

I am trying to save the SortedColumnInfoCollection to session so I can reset the grid when the user returns to it. There is no inner exception. The object that I store this information is marked a Serializalbe and it inherts ISerializable. If I take out the SortedColumnInfoCollection, it works. But I want to save that information or I will have to remove that feature from the users.  And I would rather not do that.  Does anyone know how to get around this?

Here is a copy of the Object that I am trying to Serialize.

    [Serializable]
    public class GridSettingsHolder : ISerializable
    {
        protected SortedColumnInfoCollection _columnSortInfo;
        protected ColumnFilters _columnFilters;


        public GridSettingsHolder()
        {           
        }

        public Infragistics.Web.UI.GridControls.SortedColumnInfoCollection ColumnSortingInfo
        {
            get { return _columnSortInfo; }
            set { _columnSortInfo = value; }
        }


        public Infragistics.Web.UI.GridControls.ColumnFilters ColumnFilters
        {
            get { return _columnFilters; }
            set { _columnFilters = value; }
        }


        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {           
           info.AddValue("ColumnSortingInfo", this._columnSortInfo);
            info.AddValue("ColumnFilters", this._columnFilters);           
        }

        public GridSettingsHolder(SerializationInfo info, StreamingContext ctxt)
        {

            this._columnSortInfo = (SortedColumnInfoCollection)info.GetValue("ColumnSortingInfo", typeof(SortedColumnInfoCollection));
            this._columnFilters = (ColumnFilters)info.GetValue("ColumnFilters", typeof(ColumnFilters));                       
        }       
    }

 

Parents
  • 37874
    posted

    Hello,

    SortedColumnInfoCollection class is not serializable and that's why you are getting the exception when you are using it as a property of Serializable class. I would suggest you to have a look at our Persistance framework that can help to persist control state: http://help.infragistics.com/Help/Doc/ASPNET/2013.2/CLR4.0/html/PersistenceFramework_About_Persistence_Framework.html.

    Here you can find demo samples:

    http://es.infragistics.com/products/aspnet/persistence-framework/

    Hope this helps.

Reply Children
No Data