Today I've run into a bit of a problem trying to programatically update the datasource of a rendering added to a Sitecore item. Essentially when I retrieved the LayoutDefinition details from the layout field it was sometimes coming back empty and sometimes not parsing the values correctly. Not to mention the Datasource property was always empty and the LayoutDefinition.ToXml() was returning completely different XML. Interestingly enough my search lead me to this question on StackOverflow from 2011 which relates to Sitecore 6.4.1 (I'm using 7.5). Pretty much the answer was to change: