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

Data Bound Autogenerated Datetime Format

3 Answers 143 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Guru
Top achievements
Rank 2
Guru asked on 28 Sep 2011, 05:18 PM
When binding a gridview to a datatable.defaultview and autogenerating columns, what is the best way to assign data formats to columns? In particular datetime columns to short format? All I can find in documentation is to use XAML DataFormatString of column, but I don't see the C# option to set this in the column objects.

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 29 Sep 2011, 06:44 AM
Hi,

 You can use AutoGeneratingColumn event to achieve your goal. 

Regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Guru
Top achievements
Rank 2
answered on 29 Sep 2011, 12:41 PM
Can you tell me please what autogeneratingcolumn e.Column property/method is available to set the data format of a date/datetime column to short (d)?
0
Vlad
Telerik team
answered on 30 Sep 2011, 06:55 AM
Hi,

 You can cast the column to GridViewBoundColumnBase and use either DataMemberBinding to provide format or IValueConverter or DataFormatString column property. 

Best wishes,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Guru
Top achievements
Rank 2
Answers by
Vlad
Telerik team
Guru
Top achievements
Rank 2
Share this question
or