If I try to implement, inherit StateManagedCollection i lost Temalated content after few changes(action over collection adding or reordering) templated contend disappear and show only Name of Item. This is second try for implementation:
[AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] public class TabsCollection : StateManagedCollection { private static readonly Type[] knownTypes;
static TabsCollection()
{
TabsCollection.knownTypes = new Type[] { typeof(Item) };
}
public Item this[int index]
{
get
{
if (this.Count < index)
{
return null;
}
return (Item)((IList)this)[index];
}
set
{
((IList)this)[index] = value;
}
}
public int Add(Item value)
{
return ((IList)this).Add(value);
}
public int IndexOf(Tab value)
{
return ((IList)this).IndexOf(value);
}
public void Insert(int index, Item value)
{
((IList)this).Insert(index, value);
}
public void CopyTo(Tab[] toolBarSetArray, int index)
{
base.CopyTo(toolBarSetArray, index);
}
protected override object CreateKnownType(int index)
{
return new Tab();
}
protected override Type[] GetKnownTypes()
{
return TabsCollection.knownTypes;
}
public void Remove(Item value)
{
((IList)this).Remove(value);
}
public void RemoveAt(int index)
{
((IList)this).RemoveAt(index);
}
public bool Contains(Item value)
{
return ((IList)this).Contains(value);
}
protected override void OnValidate(Object value)
{
if (value.GetType() != typeof(Item))
throw new ArgumentException("value must be of type Item.", "value");
}
protected override void SetDirtyObject(object o)
{
if (o is Item)
{
((Item)o).SetDirty();
}
}
}
SeaSol
0 Points
2 Posts
When i try to implement StateManagedCollection lost Templated content
Jan 12, 2011 10:35 AM|LINK
If I try to implement, inherit StateManagedCollection i lost Temalated content after few changes(action over collection adding or reordering) templated contend disappear and show only Name of Item. This is second try for implementation:
[AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] public class TabsCollection : StateManagedCollection { private static readonly Type[] knownTypes; static TabsCollection() { TabsCollection.knownTypes = new Type[] { typeof(Item) }; } public Item this[int index] { get { if (this.Count < index) { return null; } return (Item)((IList)this)[index]; } set { ((IList)this)[index] = value; } } public int Add(Item value) { return ((IList)this).Add(value); } public int IndexOf(Tab value) { return ((IList)this).IndexOf(value); } public void Insert(int index, Item value) { ((IList)this).Insert(index, value); } public void CopyTo(Tab[] toolBarSetArray, int index) { base.CopyTo(toolBarSetArray, index); } protected override object CreateKnownType(int index) { return new Tab(); } protected override Type[] GetKnownTypes() { return TabsCollection.knownTypes; } public void Remove(Item value) { ((IList)this).Remove(value); } public void RemoveAt(int index) { ((IList)this).RemoveAt(index); } public bool Contains(Item value) { return ((IList)this).Contains(value); } protected override void OnValidate(Object value) { if (value.GetType() != typeof(Item)) throw new ArgumentException("value must be of type Item.", "value"); } protected override void SetDirtyObject(object o) { if (o is Item) { ((Item)o).SetDirty(); } } }state management technique