Answered by:
ExtractValues and Serialization.

Question
-
User-1825738080 posted
I have a problem creating a fieldtemplate control that renders a edit/insert/readonly template for a generic IList of a serializable item.
Here is a video that shows how I get the error.
http://www.screencast.com/t/e7SbiC8G
{"Error serializing value 'System.Collections.Generic.List`1[FlexiCommerce.Components.Category]' of type 'System.Collections.Generic.List`1[[FlexiCommerce.Components.Category, FlexiCommerce, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].'"}
" at System.Web.UI.ObjectStateFormatter.SerializeValue(SerializerBinaryWriter writer, Object value)\r\n at System.Web.UI.ObjectStateFormatter.Serialize(Stream outputStream, Object stateGraph)\r\n at System.Web.UI.ObjectStateFormatter.Serialize(Object stateGraph)\r\n at System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Serialize(Object state)\r\n at System.Web.UI.Util.SerializeWithAssert(IStateFormatter formatter, Object stateGraph)\r\n at System.Web.UI.HiddenFieldPageStatePersister.Save()\r\n at System.Web.UI.Page.SavePageStateToPersistenceMedium(Object state)\r\n at System.Web.UI.Page.SaveAllState()\r\n at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)"
public partial class Categories_Edit : FieldTemplateUserControl
{
private IList<category> categories;
public override void DataBind()
{
if (Host.Mode == DataBoundControlMode.Edit)
{
categories = FieldValue as IList<category>;
}
base.DataBind();
}
protected override void ExtractValues(System.Collections.Specialized.IOrderedDictionary dictionary)
{
IList<category> newcategories = new List<category>();
foreach (RadTreeNode node in RadTreeViewCategories.CheckedNodes)
{
Category category = FlexiCommerce.Context.Persister.Get(int.Parse(node.Value)) as Category;
if (category != null)
newcategories.Add(category);
}
dictionary[Column.Name] = newcategories;
}
protected void TreeView_DataBound(object sender, EventArgs e)
{
if (this.Host.Mode == DataBoundControlMode.Edit)
{
foreach (Category c in categories)
{
RadTreeNode node = RadTreeViewCategories.FindNodeByValue(c.ID.ToString());
if (node != null)
{
node.Checked = true;
node.ExpandParentNodes();
}
}
}
}
}</category></category></category></category>
Wednesday, January 7, 2009 3:45 AM
Answers
All replies
-
-
User-1825738080 posted
Hi Theonlylawislove, have a look at this article here there is a response about half way down mentioning a similar problem ans possible solution.
Thank you so much!
[NonSerialized]
private IList<product> products = new List<product>();</product></product>That did the trick!
Wednesday, January 7, 2009 5:51 AM