Displaying values in a drop down list field within transformation

   —   
This article describes how to display text values from the drop-down list's "key;value" pair on the live site using transformation.
You have a drop-down field with pair values like:
1;Nokia
2;Sony Ericsson
3;Motorola


And now on the site you want to display the values in the drop-down and not the keys.
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;
}
</script>
Manufacturer:<%# GetName(Eval("ManufacturerId")) %>


See also: Or our sample E-commerce site: Site Manager -> Development -> Document types -> Product - Laptop -> Transformations -> Default

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.