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));                       
        }       
    }