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

How do I show mm/yyyy on cells

3 Answers 33 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tao Jiang
Top achievements
Rank 1
Tao Jiang asked on 04 Nov 2009, 03:28 PM
Hi,

I tried to show mm/yyyy on gridview with the code

CultureInfo

 

cultureInfo = new CultureInfo("en-US");

 

 

DateTimeFormatInfo dateInfo = new DateTimeFormatInfo();

 

dateInfo.ShortDatePattern =

"MM/yyyy";

 

cultureInfo.DateTimeFormat = dateInfo;

 

Style datePickerStyle = new Style(typeof(RadDatePicker));

 

datePickerStyle.Setters.Add(

new Setter(RadDatePicker.CultureProperty, cultureInfo));

 

datePickerEditorSettings.CellEditStyle = datePickerStyle;

 

 

 

((

GridViewDataColumn)this.radGridViewData.Columns[1]).EditorSettings = datePickerEditorSettings;

It crashes, but if I change MM/yyyy to MM/dd/yyyy, the cells shows MM/dd/yyyy 12:00 AM.

Thanks so much for any help.

 

3 Answers, 1 is accepted

Sort by
0
Stefan Dobrev
Telerik team
answered on 04 Nov 2009, 04:58 PM
Hi Tao,

You can use the DataFormatString property of the GridViewDataColumn to apply custom formatting.

Please note that we have obsoleted editor settings in our 2009 Q3 release.

Kind regards,
Stefan Dobrev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tao Jiang
Top achievements
Rank 1
answered on 04 Nov 2009, 05:04 PM
Thank you for the response, Stefan Dobrev.

I did it like what you said. But I bind this column to database field, which is string.
So it does not work that way.

Any idea?
0
Stefan Dobrev
Telerik team
answered on 04 Nov 2009, 05:32 PM
Hello Tao,

You can use the Converter property of the binding to specify custom IValueConverter that will convert the value from string to date time.

Kind regards,
Stefan Dobrev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Tao Jiang
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
Tao Jiang
Top achievements
Rank 1
Share this question
or