This is a migrated thread and some comments may be shown as answers.

Can I replace this format string with variable

1 Answer 91 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
swegele
Top achievements
Rank 1
swegele asked on 05 Aug 2010, 01:42 AM
I have a GridBoundColumn with this property
DataFormatString="{0:dd-MMM-yyyy hh:mm:ss tt}"

This works nicely...BUT...I have an application setting variable with this so if the format changes I don't have to change it in a million places.  It is this variable:
MyWeb.Properties.Settings.Default.DateFormatString

NOT in the codebehind...Is there any way to replace the string with a server variable or something in the aspx?  Maybe some <%= %> or eval or other method?

1 Answer, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 10 Aug 2010, 03:03 PM
Hello Mark,

To implement the desired functionality, I recommend that you set the date format in the web.config file and then bind it to the DataFormatString of the corresponding column:
web.config
<configuration>
    <configSections>
       
        <appSettings>
             <add key="GridDateFormat" value="{0:yyyy/dd/MM}" />
         </appSettings>
   
    </configSections>
</configuration>
ASPX
<telerik:GridDateTimeColumn DataFormatString="<%$Appsettings:GridDateFormat%>" ... >
</telerik:GridDateTimeColumn>

I hope this helps.

Regards,
Mira
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
swegele
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or