ASPX templates
Version 4.x > ASPX templates > How to make autoresponder get the text value of dropdownList entries View modes: 
User avatar
Member
Member
whiplash - 9/20/2012 8:57:09 AM
   
How to make autoresponder get the text value of dropdownList entries
Hey Guys and Girls

Does anyone know how to pull back the text value of the dropdown value stored in the database?

My scenario is that someone registers and selects options for which event they want to register. The autoresoonder email macro elements are bringing back the index of the value instead of the text value.

eg:

1;value1
2;value2
3;value3

How can I display 'value1' instead of '1' in the email body?


Much appreciated

Whiplash

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 9/21/2012 1:36:51 AM
   
RE:How to make autoresponder get the text value of dropdownList entries
Hello,

The easiest way would be to modify the dropdown values to:

value1;value1
value2;value2
value3;value3

Otherwise you will need to create a macro or custom transformation function, which would get the data from the database by accessing the class definition and extracting the name. Here is some sample code, which could be used after siome modification:

using CMS.FormEngine;
using CMS.SettingsProvider;
...

DataClassInfo dci = DataClassInfoProvider.GetDataClass("cms.user");
if (dci != null)
{
FormInfo fi = new FormInfo(dci.ClassFormDefinition);
FormFieldInfo ffi = fi.GetFormField(ÜserIsExternal");
if (ffi != null)
{
// now you can work with the FormFieldInfo
FormFieldDataTypeEnum dataType = ffi.DataType;
}
}

Here is some example code for the object CMS.Article and the field MyDropdown:

//getting the DataClassInfo for the given object (e.g. cms.article)
CMS.SettingsProvider.DataClassInfo di = CMS.SettingsProvider.DataClassInfoProvider.GetDataClass("CMS.Article");

//creating a new FormInfo object
CMS.FormEngine.FormInfo fi = new CMS.FormEngine.FormInfo(di.ClassFormDefinition);


//getting the field
CMS.FormEngine.FormFieldInfo ffi = fi.GetFormField("MyDropdown");


//acessing all the fields options
Label1.Text = ffi.Settings[Öptions"].ToString();

Best regards,
Boris Pocatko

User avatar
Member
Member
whiplash - 9/21/2012 6:51:47 AM
   
RE:How to make autoresponder get the text value of dropdownList entries
Thankyou very much Boris, I managed to get the solution for your first suggestion, not very elegant, but it works. If I get time to play about with your second suggestion then I might see if I can implement that :)

Regards