Custom Property PropertyData losing value

Vote:
 

Hi all, I have a compund custom property with 3 dropdowns. The selection of each dropdown populates sub-dropdowns..etc. The property type is of type PropertyLongString.

When 'AppyEditChanges()' is called, I call 'SetValue()' and I store the value as: droipdownvalue1~dropdownvalue2~dropdownvalue3, and this works fine in storing the value.

When the control is loaded in edit mode and 'CreateEditControls()' is called, I do the following:

 

if (this.PropertyData.Value != null)
{
  
string[] selections = this.PropertyData.Value.ToString().Split('~');
   ........

I then take the split values and set the appropriate selected values for each dropdownlist. This all works fine.

The problem is that the value in 'this.PropertyData' seems to be cleared randomly. So when the page loads, the appropriate dropdowns dont get set their previously saved value. This seems to be intermittent. Sometimes it works and other times not.

Any help would be much appreciated.

thank you

#41821
Jul 29, 2010 15:41
Vote:
 

I can't really point you in any direction without seeing more of the code, but I can say that I have had similar problems several times. Values disappearing upon re-saving a page, copying a page etc. And it has always turned out to be some kind of error in my logic. So keep looking, debug and step through the code and sooner or later you'll fingure it out!

#41822
Jul 29, 2010 16:10
Vote:
 

Hi Magnus, thank you for your reply - always helpful as usual.

I figured it out. As I had three dropdowns on the page, I decided to not make use of the base.Editcontrol dropdownlist. When saving the page i.e.) ApplyEditChanges(), I was still calling base.ApplyEditChanges(), which using Reflector, I realised was doing the following:

 "SetValue(EditControl.SelectedValue)"

...and as base.EditControl was not being used, its selecetValue property was null. So my value was being over-written by null.

So once I removed base.ApplyEditChanges(), my code worked fine and the values were no longer removed.

Thank you once again!

#41825
Jul 29, 2010 17:42
Vote:
 
#41826
Jul 29, 2010 17:42
Vote:
 

Hi Mohammed Laies,

                                 Can you share your code with me 

#53132
Aug 29, 2011 15:15
Vote:
 

Hi Karan,

as there is a lot of code, it would probably be best if you email me at mohammedlaies@yahoo.co.uk and I will send you the code.

thanks

 

#53196
Aug 31, 2011 13:47
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.