Getting The Selected DropLink Item In Sitecore using Synthesis

I recently inherited a Sitecore project that used Synthesis to do the ORM. If you want to read more about Synthesis you can read more about it here, How To Map Sitecore Objects into C# Objects using Synthesis. In my Sitecore template, I needed to get the value from a dropdown list. Figuring out the code needed to do this wasn't as intuitive as I hoped and after an hour of head scratching, I finally managed to get the value I wanted using the below code:

  var standardTemplateItem = new StandardTemplateItem();
  var fields = standardTemplateItem.ItemReferenceField.Target.InnerItem.Fields;
  var value = fields.Where(X => X.DisplayName == "Value").Select(x => x.Value).FirstOrDefault();
I'm hoping this might be useful for someone!

Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge

Back to top
var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-35662136-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + ''; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();