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

DataFormatString for dates in GridViewDataColumn

3 Answers 480 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Big_G
Top achievements
Rank 1
Big_G asked on 15 Sep 2010, 04:27 PM
I have the following code but getting an error. My grid doesn't render at all.

I need to format the date in this column to not show the time.

xmlns

 

 

:System="clr-namespace:System;assembly=mscorlib"

 

 

 

 

....
 

 

<tlk:GridViewDataColumn DataMemberBinding="{Binding TradeDate}" DataType="System:DateTime"  

 

Width="70" DataFormatString="{}{0:M/dd/yyyy}" 

 

 

UniqueName="TradeDate" >
<tlk:GridViewDataColumn.Header>
<TextBlock Text="Trade Date" TextWrapping="Wrap" />  

 

 

 

</tlk:GridViewDataColumn.Header>
</tlk:GridViewDataColumn>

 

 

3 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 15 Sep 2010, 04:39 PM
Hi Giancarlo,

What  does the error say?

Please remove the DataType property and see if this helps.

You can try to bind to the Date portion of the DateTime object like so:

<tlk:GridViewDataColumn DataMemberBinding="{Binding TradeDate.Date}" ... />


Regards,
Veselin Vasilev
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
0
Big_G
Top achievements
Rank 1
answered on 15 Sep 2010, 06:39 PM
I tried doing both your suggestions to no luck. There's no error but my grid won't show up.

Anything else I can try? Earlier, my TradeDate was a string type. I changed it to DateTime but it still doesn't work as it should. The time still shows up as 00:00:00
0
Veselin Vasilev
Telerik team
answered on 17 Sep 2010, 02:07 PM
Hello Big_G,

Find attached a sample project. Let me know if you manage to reproduce the problem in it.

All the best,
Veselin Vasilev
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
GridView
Asked by
Big_G
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Big_G
Top achievements
Rank 1
Share this question
or