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

Formatting Date Time ?

1 Answer 67 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Prince M. Premnath
Top achievements
Rank 2
Prince M. Premnath asked on 28 Apr 2010, 03:18 PM
Hello All ,

While assigning the DataField ( Date Time Object from Data Source ) how just i can format the date , it takes up the default style ( as store in database )

here is my code excerpt

                        oBoundColumn = new GridBoundColumn();
                        oBoundColumn.DataType = Type.GetType("System.DateTime");
                        oBoundColumn.UniqueName = "EndDate";
                        oBoundColumn.HeaderText = "End Date";
                        oBoundColumn.DataField = "EndDate";

Thanks
-Prince



1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Apr 2010, 05:44 AM
Hello Prince,

You can use the DataFormatString property of Column in order to format the date.

CS:
        oBoundColumn = new GridBoundColumn();
        oBoundColumn.DataType = Type.GetType("System.DateTime");
        oBoundColumn.DataFormatString = "{0:dd/MM/yyyy}";   // Set the format

Also check out documentation which describes on this: Using columns

-Shinu.
Tags
Grid
Asked by
Prince M. Premnath
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or