Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Is there a best practice for using a Country Selector field in a transformation? View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
SkippyFiRe - 11/11/2010 1:29:28 PM
   
Is there a best practice for using a Country Selector field in a transformation?
Just trying to ouput the state and country separately, and here is what I have:
State: <%# Eval<string>("CountryState").Split(';')[1] %>
Country: <%# Eval<string>("CountryState").Split(';')[0] %>

Is there a better way to do this?

Thanks,
John

User avatar
Member
Member
kentico_michal - 11/17/2010 3:17:32 AM
   
RE:Is there a best practice for using a Country Selector field in a transformation?
Hi John,

Regrettably, there is no better way how to do this. Anyway, I would recommend you to use custom transformation methods to achieve this aim.

You could use following custom method:

public static string getCountry(object CountryState)
{
string txtCountryState = (string) CountryState;

string country = txtCountryState.Split(';')[0];

return country;
}

public static string getState(object CountryState)
{
string txtCountryState = (string) CountryState;

string state = txtCountryState.Split(';')[1];

return state;
}

In transformation you could use following definition to resolve these methods:
<%# MyFunctions.getState(Eval("CountryState"))%>
<%# MyFunctions.getCountry(Eval("CountryState"))%>



Best regards,
Michal Legen

User avatar
Certified Developer v7
Certified  Developer v7
John Bubriski - 11/17/2010 7:59:17 AM
   
RE:Is there a best practice for using a Country Selector field in a transformation?
OK, thanks for the info Michal. Maybe we can suggest this for version 6.x? Maybe have a built in function or macro?

User avatar
Member
Member
kentico_michal - 11/18/2010 3:56:52 AM
   
RE:Is there a best practice for using a Country Selector field in a transformation?
Hi,

Thank you for your suggestion. I have set it as a requirement and we will consider this feature for future versions of Kentico CMS.

Best regards,
Michal Legen