if you store an unserializable object in a table, then it is no longer
serilizable. you will need to write a serializer/deserialzer for each of
your controls.
-- bruce (sqlwork.com)
Adam wrote:
> I need to store a collection of dynamically loaded controls in my User
> Control. Each control is linked to a headerid and a headerid can have many
> controls. My first dead end was to use a List<int, Control>, but that would
> not serialize at all. I since changed to using a DataTable. My DataTable is
> not serializing (the error message is the title of this post). Please help.
> Here is some code:
>
> private DataTable LoadedControlsDT
> {
> get
> {
> if (ViewState[LocalViewStateKeys.LoadedCtrls] == null)
> {
> DataTable dt = new DataTable();
> DataColumn dc = new DataColumn("headerid", typeof(int));
> dt.Columns.Add(dc);
>
> dc = new DataColumn("control", typeof(Control));
> dt.Columns.Add(dc);
>
> ViewState[LocalViewStateKeys.LoadedCtrls] = dt;
> }
> return (DataTable)ViewState[LocalViewStateKeys.LoadedCtrls];
> }
> set
> {
> ViewState[LocalViewStateKeys.LoadedCtrls] = value;
> }
> }
|