kentico_michal
-
11/1/2010 4:14:06 PM
RE:Get the Display Value of a DropDownList Control in a Transformation
Hi,
Please keep in mind that the first value from the pair (for example 1;option1 ) is stored in the database (value 1 in this case) and the second one (string option1) is used only to display in drop-down list.
Eval method use value from database, so this is the reason why value 1 is displayed.
One way how to achieve displaying Option1 (or Option2) could be based on custom transformation method (please find more information in Developer's guide http://devnet.kentico.com/docs/devguide/index.html?adding_custom_functions_to_transformations.htm).
You could use for example following code in that custom method: public static string customFunction(object input) { string option = (string)input; if (option.Equals("1")) return "Option 1"; else if (option.Equals("2")) return "Option 2"; return "Undefined"; }
<%# MyFunctions.customFunction(Eval("fieldName")) %>
Second way could be changing the way how you define drop-down list options to following definition, so that string Option1 was stored in database instead of value 1:
Option1;option1
Best regards, Michal Legen
|