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

How do I get date columns to recognize the culture of the radgrid?

5 Answers 178 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Javier
Top achievements
Rank 1
Javier asked on 28 Aug 2012, 06:14 PM
I have a radgrid and the dates should be formatted to display in the proper culture.

I set the culture in the radgrid as follows

<telerik:RadGrid runat="server" ID="rgdGroupOrder" CellSpacing="0" GridLines="None" Culture="en-AU">

The date columns are databound to datetime objects.

<telerik:GridBoundColumn DataField="ScheduleDateTime" DataType="System.DateTime" FilterControlAltText="Filter ScheduleDateTime column"
    HeaderText="Schedule Date/Time" SortExpression="ScheduleDateTime" UniqueName="ScheduleDateTime" >
</telerik:GridBoundColumn>

No matter what I do the datetime formats always appear in the US format (mm/dd/yyyy) when they should be (dd/mm/yyyy).

I would like to apply a standard date format to these columns as well to clean up the way they look.  So the markup will look like this.

<telerik:GridBoundColumn DataField="ScheduleDateTime" DataType="System.DateTime" FilterControlAltText="Filter ScheduleDateTime column"
    HeaderText="Schedule Date/Time" SortExpression="ScheduleDateTime" UniqueName="ScheduleDateTime" DataFormatString="{0:g}">
</telerik:GridBoundColumn>


The only difference is that the DataFormat property is set.

Thanks

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 31 Aug 2012, 07:53 AM
Hi,

Try setting the DataFormatString as shown below.

ASPX:
<telerik:GridBoundColumn DataField="ScheduleDateTime" DataType="System.DateTime" FilterControlAltText="Filter ScheduleDateTime column"
    HeaderText="Schedule Date/Time" SortExpression="ScheduleDateTime" UniqueName="ScheduleDateTime" DataFormatString="{0:dd/MM/yyyy}">
</telerik:GridBoundColumn>

Thanks,
Shinu.
0
Javier
Top achievements
Rank 1
answered on 31 Aug 2012, 11:45 AM
Thank for the help, but that won't solve my problem. The culture will be set dynamically per user which is why I'm using it.  
I just hard coded it for the example for the sake of simplicity.

We have clients in different parts of the world, and their culture is set for their own installation of the software.

Is this a bug, what is the culture setting of the grid supposed to do?  Should I open a ticket?

Thanks
0
Radoslav
Telerik team
answered on 03 Sep 2012, 08:19 AM
Hello Javier,

To achieve the desired functionality you need to set the Culture to the page where the RadGrid is placed. For example:
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" Culture="en-AU" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>
I am sending you a simple example which demonstrates that. Please check it out end let me know if it helps you.

Regards,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Javier
Top achievements
Rank 1
answered on 14 Sep 2012, 01:33 PM
That worked perfectly, thanks.
0
Alex
Top achievements
Rank 1
answered on 17 Jan 2018, 06:41 PM
Then what is the purpose of setting the grid culture if it does nothing
Tags
Grid
Asked by
Javier
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Javier
Top achievements
Rank 1
Radoslav
Telerik team
Alex
Top achievements
Rank 1
Share this question
or