London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Changing Selected/not Selected Property Dynamically

Vote:
 

Hello,

I'm trying to change a radio button property from a Edit plugin in the parent of some children pages. I am cloning each of the pages to make them writable. The problem is that I don't seem to be able to change the value of the Selected/not Selected property. However, I am able to change other properties that are text for example. I wonder if there is a special extra step that needs to be done for these type of properties (selected/not selected)?

Here's the code:

protected void SelectHeroImage_CheckedChanged(object sender, EventArgs e)
{
string pageID = ((CBSOutdoor.Classes.RepeatableRadioButton)(sender)).SelectedPageId;
foreach (PageData pd in ((PageDataCollection)imageList.DataSource))
{
//Get a writable PageData object to modify
//PageData myWritablePage = EPiServer.DataFactory.Instance.GetPage(pd.PageLink);
PageData myWritablePage = pd.CreateWritableClone();
if (pd.PageLink.ID == Convert.ToInt32(pageID))
{
myWritablePage.Property["HeroImage"].Value = true;
//myWritablePage.Property["Keywords"].Value = "Value is True";
}
else
{
myWritablePage.Property["HeroImage"].Value = false;
//myWritablePage.Property["Keywords"].Value = "Value is False";
}

//Perform 'Save and publish' programmatically
DataFactory.Instance.Save(myWritablePage, SaveAction.Publish);
}

LoadPages();
}

Thanks.


Victor

#28478
Mar 10, 2009 13:09
Vote:
 

When you check the value for a PropertyBoolean its either null or true:

if(myPropertyBoolean.IsNull)
    // its false
else
    // its true

So try to set it to null instead of false. Just an idea that came to mind. Havent tested it.

/Hans

 

#28481
Mar 10, 2009 16:46
Vote:
 

Hi

 

I got into almost the same problem myself regarding setting the value for a selected/not selected property. It seems that it's not possible to set the value in a dynamic property of type selected/not selected to the value "not selected". 

Read this thread for explanation:

http://world.episerver.com/Forum/Pages/Thread.aspx?id=13118&epslanguage=en

#30199
Jun 05, 2009 14:10
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.