Hello!
I use a GridView bound to a data table. One of the columns in the data table stores a date information in Unix format (milliseconds since 1970). I have used a converter similar to the one described in the converting data types example.
When i use "DateTime" for the CanConvertTo method and "long" for the "CanConvertFrom" the column shows the milliseconds value and not a valid DateTime string. Changing the "CanConvertTo" to "long" and the "CanConvertFrom" method to "DateTime" still keeping the "ConvertTo" method converting from "long" to "DateTime" i get valid date strings in the GridView. When I try to filter on that column I get an "InvalidCastException" in the "ConvertTo" method where the "Value" is a "DateTime" object and the destination type is Int64.
When i change the "ConvertTo" and and "ConvertFrom" methods to check for "value" type and transform to "DateTime" iv "Value" type is "long" or "long" if "value" type is "DateTime".
Using this I get a "FilterExpressionException" with the inner exception message {"Cannot perform '>=' operation on System.Int64 and System.DateTime."}
When i then take into account the "destinationType" in the convert method and make a transformation of the "value" object to the selected destination type the date string is again not valid (as in the first case).
Have I missed something or is there a bug?
Thanks for your help.
I use a GridView bound to a data table. One of the columns in the data table stores a date information in Unix format (milliseconds since 1970). I have used a converter similar to the one described in the converting data types example.
When i use "DateTime" for the CanConvertTo method and "long" for the "CanConvertFrom" the column shows the milliseconds value and not a valid DateTime string. Changing the "CanConvertTo" to "long" and the "CanConvertFrom" method to "DateTime" still keeping the "ConvertTo" method converting from "long" to "DateTime" i get valid date strings in the GridView. When I try to filter on that column I get an "InvalidCastException" in the "ConvertTo" method where the "Value" is a "DateTime" object and the destination type is Int64.
When i change the "ConvertTo" and and "ConvertFrom" methods to check for "value" type and transform to "DateTime" iv "Value" type is "long" or "long" if "value" type is "DateTime".
Using this I get a "FilterExpressionException" with the inner exception message {"Cannot perform '>=' operation on System.Int64 and System.DateTime."}
When i then take into account the "destinationType" in the convert method and make a transformation of the "value" object to the selected destination type the date string is again not valid (as in the first case).
Have I missed something or is there a bug?
Thanks for your help.