Take the community feedback survey now.
AI OnAI Off
Take the community feedback survey now.
example of the issue can be seen here : http://screencast.com/t/0Tr8y2c3Vqm
My initial thoughts are PageTypeCollection cannot be saved into the DDS so will try converting this into an IntegerCollection
After a bit of faffing around and changing the PropertyType this is now working. I changed it to string value and saving the options as Comma delimiated integers.
Hi Guys
I have created a custom property which allows a user to select a number of PageTypes located in a MultiSelect control, I wanted to limit the page types which get shown in this control so decided to use Custom settings, so i can select the page types i would want to show in my property.
The issue i am having is everytime i select the PageTypes via a checkbox and try to save i get the following error : Property Id must be of type System.Guid or EPiServer.Data.Identity
Just as a test I added another TextBox field as well into here to see if i edit only this would my settings save and yes they do save as long as i do not select any page types in the checkbox list.
Has anyone came across this before ?
Code below for Settings Class
[EPiServerDataContract] [EPiServerDataStore(AutomaticallyRemapStore = true)] [PropertySettingsUI(AdminControl = typeof(PageTypeSelectorSettingsUI))] [Serializable] public class PageTypeSelectorSettings : IPropertySettings { public PageTypeSelectorSettings() { PageTypes = null; TestTemp = string.Empty; } #region Public Properties [EPiServerDataMember] public PageTypeCollection PageTypes { get; set; } [EPiServerDataMember] public string TestTemp { get; set; } #endregion #region Implementation of IPropertySettings public IPropertySettings GetDefaultValues() { return new PageTypeSelectorSettings(); } public IPropertySettings Copy() { var settings = new PageTypeSelectorSettings(); settings.PageTypes = this.PageTypes; settings.TestTemp = this.TestTemp; return settings; } public Guid Id { get; set; } #endregionCode below for SettingsUI
public class PageTypeSelectorSettingsUI : PropertySettingsControlBase { #region Constants and Fields private CheckBoxList pageTypeCollection; private TextBox tempTest; #endregion #region Overrides of PropertySettingsControlBase public override void LoadSettingsUI(IPropertySettings propertySettings) { this.EnsureChildControls(); var settings = propertySettings as PageTypeSelectorSettings; if (settings == null) { return; } if (settings.PageTypes != null) { foreach (var pageType in settings.PageTypes) { ListItem myListItem = this.pageTypeCollection.Items.FindByText(pageType.Name); myListItem.Selected = true; } } this.tempTest.Text = settings.TestTemp; } public override void UpdateSettings(IPropertySettings propertySettings) { this.EnsureChildControls(); var settings = propertySettings as PageTypeSelectorSettings; if (settings == null) { return; } settings.PageTypes = GetPageTypeCollection(); settings.TestTemp = tempTest.Text; } #endregion #region Methods protected override void CreateChildControls() { base.CreateChildControls(); this.pageTypeCollection = new CheckBoxList{ID = "PageTypeList"}; this.pageTypeCollection.RepeatColumns = 3; this.pageTypeCollection.RepeatDirection = RepeatDirection.Vertical; this.pageTypeCollection.RepeatLayout = RepeatLayout.Table; this.pageTypeCollection.CssClass = "epi-dataTable"; this.pageTypeCollection.DataSource = (object)PageType.List(); this.pageTypeCollection.DataTextField = "Name"; this.pageTypeCollection.DataValueField = "ID"; this.pageTypeCollection.DataBind(); var label = new Label { Text = "Page Types", AssociatedControlID = "PageTypeList" }; this.AddNewRow(label, this.pageTypeCollection); this.tempTest = new TextBox { ID = "TempText" }; var labtest = new Label { Text = "Test", AssociatedControlID = "TempText" }; this.AddNewRow(labtest, this.tempTest); } private PageTypeCollection GetPageTypeCollection() { var collection = new PageTypeCollection(); foreach (ListItem listItem in this.pageTypeCollection.Items) { if (listItem.Selected) { int id = int.Parse(listItem.Value); collection.Add(PageType.Load(id)); } } return collection; } #endregion }