Displaying values from a drop down list field

This article describes how to display values from a drop down list in a transformation.
You have a drop down field with pair values like:

2;Sony Ericsson

And now on the site you want to display the values in the drop down and not the indexes.
It is needed to hard code decision logic directly in the transformation. Please find the example below:

<script runat="server">
string GetName(object CodeName) {
if (CodeName != null) {
string Code = CodeName.ToString();
switch (Code) {
case "1": return "Nokia";break;
case "2": return "Sony Ericsson"; break;
case "3": return "Motorola"; break;
return (string)CodeName;
Manufacturer:<%# GetName(Eval("ManufacturerId")) %>

See also:

Applies to: Kentico CMS 3.x
Share this article on   LinkedIn

Juraj Ondrus

Hi, I am the Technical support leader at Kentico. I'm here to help you use Kentico and get as much as possible out of it.