Keith Stephens
Top achievements
Rank 1
Keith Stephens
asked on 17 Aug 2010, 04:07 PM
Hi all,
I have searched this forum and did not find an answer.
I am using SL3 and VS 2008 I have a gridview and I bind it to a observable collection and in this collection I have 2 date time fields.
When I bind to the gridview the grid displays the Date and Time, and I just want it to show the date, and when the grid goes into edit mode it changes to the datetime picker which is fine.
How can I achive my desired results of just displaying the date portion. I have tried formating the date in my code behind but it still shows the time value. I have tried using the mask control but no luck.
I have searched this forum and did not find an answer.
I am using SL3 and VS 2008 I have a gridview and I bind it to a observable collection and in this collection I have 2 date time fields.
When I bind to the gridview the grid displays the Date and Time, and I just want it to show the date, and when the grid goes into edit mode it changes to the datetime picker which is fine.
How can I achive my desired results of just displaying the date portion. I have tried formating the date in my code behind but it still shows the time value. I have tried using the mask control but no luck.
8 Answers, 1 is accepted
0
Hi Keith Stephens,
Greetings,
Yavor Georgiev
the Telerik team
You should set the CellTemplate property of your column to something like:
<
DataTemplate
>
<
TextBlock
Text
=
"{Binding MyDateProperty, StringFormat=d}"
/>
</
DataTemplate
>
Yavor Georgiev
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
Keith Stephens
Top achievements
Rank 1
answered on 17 Aug 2010, 04:22 PM
Looks good, but I could not get it to work. The error I got was Error 3 The property 'StringFormat' does not exist on the type 'Binding' in the XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'.
<
telerikGridView:GridViewDataColumn
>
<
telerikGridView:GridViewDataColumn.Header
>
<
StackPanel
Orientation
=
"Vertical"
>
<!-- This display the wording Date under Begin.-->
<
TextBlock
Text
=
"Begin"
HorizontalAlignment
=
"Left"
/>
<
TextBlock
Text
=
"Date"
HorizontalAlignment
=
"Left"
/>
</
StackPanel
>
</
telerikGridView:GridViewDataColumn.Header
>
<
telerikGridView:GridViewDataColumn.CellTemplate
>
<
DataTemplate
>
<
TextBlock
Text
=
"{Binding Path=BeginDate, StringFormat=d}"
/>
</
DataTemplate
>
</
telerikGridView:GridViewDataColumn.CellTemplate
>
</
telerikGridView:GridViewDataColumn
>
0
Hello Keith Stephens,
Yavor Georgiev
the Telerik team
Are you using Silverlight 3?
Sincerely yours,Yavor Georgiev
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
Keith Stephens
Top achievements
Rank 1
answered on 17 Aug 2010, 04:25 PM
Yes I am using silverlight 3 with visual studio 2008.
0
Hello Keith Stephens,
Yavor Georgiev
the Telerik team
In this case you would need to use an IValueConverter for the binding, instead of StringFormat. Example.
All the best,Yavor Georgiev
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
Keith Stephens
Top achievements
Rank 1
answered on 17 Aug 2010, 04:45 PM
That worked great, but now it seems that I am dealing with text rather than a date time. Is this correct?
Do I need to add a datetime picker to the cell edit template, to get that functionality back?
Hate to bombard you with so many questions, but I am very new at SL and Telerik controls.
Thanks,.
Do I need to add a datetime picker to the cell edit template, to get that functionality back?
Hate to bombard you with so many questions, but I am very new at SL and Telerik controls.
Thanks,.
0
Hi Keith Stephens,
Yavor Georgiev
the Telerik team
If you set the converter in the binding of the TextBlock in the CellTemplate, but not in the column's DataMemberBinding property, you should still get a DateTimePicker in edit mode.
Greetings,Yavor Georgiev
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
Keith Stephens
Top achievements
Rank 1
answered on 17 Aug 2010, 04:54 PM
Got it.. Thank you. I had removed the binding on the column and just had it on the textblock.
Many thanks.
Many thanks.