This question is locked. New answers and comments are not allowed.
When I create a GridView at runtime and try to format a date column, the application crashes with the following error:
"Input string was not in a correct format"
Have I got the syntax wrong for the DataFormatString property? I am trying to format the date column so that it only shows the date. My code is below which recreates the problem:
"Input string was not in a correct format"
Have I got the syntax wrong for the DataFormatString property? I am trying to format the date column so that it only shows the date. My code is below which recreates the problem:
Imports Telerik.Windows.ControlsImports System.Windows.DataPartial Public Class MainPage Inherits UserControl Public Sub New() InitializeComponent() Dim StrongTypedGridView As New Telerik.Windows.Controls.RadGridView StrongTypedGridView.AutoGenerateColumns = False StrongTypedGridView.Columns.Add(New GridViewDataColumn With {.DataMemberBinding = New Binding("NameField"), .Header = "Name"}) StrongTypedGridView.Columns.Add(New GridViewDataColumn With {.DataMemberBinding = New Binding("DateField"), .Header = "Date", .DataFormatString = "{}{0:d}"}) StrongTypedGridView.ItemsSource = GetStrongData() LayoutRoot.Children.Add(StrongTypedGridView) End Sub Private Function GetStrongData() As List(Of StrongClass) Dim build As New List(Of StrongClass) build.Add(New StrongClass With {.NameField = "Fred", .DateField = DateTime.Now}) build.Add(New StrongClass With {.NameField = "Bill", .DateField = DateTime.Now}) Return build End Function Public Class StrongClass Public Property NameField As String Public Property DateField As DateTime End ClassEnd Class