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:
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 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;
}
</script>
Manufacturer:<%# GetName(Eval("ManufacturerId")) %>
See also: Applies to: Kentico CMS 3.x