I have quite a nasty issue. As trivial as it may look it is so much more frustrating now. In VB6 or earlier versions, or using 3rd party tools would be âwalk thru the parkâ. Never the less now itâs not fun anymore.
Iâm getting data from MS-SQL Server and everything is fine as long as date field is loaded as a datetime().
Never the less display of it is rather ambiguous from user standpoint (i.e. 01/02/2006 could be taken as Feb-01 or Jan-02).
Now if I convert() output datetime() field to string (varchar(), char()) I get exactly what users want to see (in any format they want) but then sorting of the grid becomes meaningless (it is sorted as a string). This is an important feature for the users, exactly on that column.
This is windows based application, delivered in C# v1.1 (
VB.NET responses would be perfectly fine too).
Iâm already using MS datagridâs TableStyles property to set fields individual GridColumnStyles[ ].Width().
I tried DataGridTextBoxColumn(),PropertyDescriptor() and other relevant aspects but somehow it didnât have any bearings on the result. I guess Iâm missing some important bit there.
All sample codes I found do address mainly ASP.NET approach or using code generated data then adding column to the grid.
My issue is to format a column as a date in order to sort properly. I see two possible approaches:
- Getting data in as datetime() then format column to meaningful display
- Getting data in as string (varchar,char) then format column to Date format for sorting reason.
Any response would be greatly appreciated. Alternative approach is great too in case if I missed something.
Thanks