yoyosh
January 29th, 2008, 02:33 AM
How to display a date in GridView in a custom manner? eg. yyyyMMdd instead of eg. 2008-01-21 00:00:00
Thanks for help
Thanks for help
|
Click to See Complete Forum and Search --> : [RESOLVED] GridView custom date display yoyosh January 29th, 2008, 02:33 AM How to display a date in GridView in a custom manner? eg. yyyyMMdd instead of eg. 2008-01-21 00:00:00 Thanks for help Shuja Ali January 29th, 2008, 02:18 PM How to display a date in GridView in a custom manner? eg. yyyyMMdd instead of eg. 2008-01-21 00:00:00 Thanks for help In case you are using DataBinder.Eval then you can add another parameter {0,D}. I don't remember it correctly, a search on Google will give you exact result. yoyosh January 30th, 2008, 11:37 AM gurmetka - you didn`t answer to my question shuja - sorry but I don`t really understand your answer... Shuja Ali January 30th, 2008, 01:23 PM gurmetka - you didn`t answer to my question shuja - sorry but I don`t really understand your answer... Easiest way would be to format it in the query itself that you use to fill a dataset. Use DatePart function of SQL Server (in case you are using SQL) to get year, month and day, and then concatenate them. yoyosh January 31st, 2008, 11:29 AM Easiest way would be to format it in the query itself that you use to fill a dataset. Use DatePart function of SQL Server (in case you are using SQL) to get year, month and day, and then concatenate them. I don`t think it would a good idea. Method from dataset returns a 'DateTime?' so it always has all fields (like year, month,day, hours, minutes, seconds) even if they haven`t been initialized (value = 0). It is my case too - I`m keeping only date, the other fields are equal to 0. You have to pass DateTime? object whatsoever. I think that the problem to be solved is only formatting issue. Shuja Ali February 1st, 2008, 02:33 AM Have you tried what I suggested before writing that it will not solve the problem. Also have you looked at DataGridViewCellStyle class? yoyosh February 1st, 2008, 05:16 AM Have you tried what I suggested before writing that it will not solve the problem. Also have you looked at DataGridViewCellStyle class? I have already wrote that all other fields of DateTime variable (other than year, month, day) are equal to 0. DataGridViewCellStyle to GridView control? yoyosh February 1st, 2008, 05:33 AM The solution was quite simple. Each column has stringFormat proprty which has to be set to something like this: {0:yyyyMMdd} Shuja Ali February 2nd, 2008, 03:58 PM The solution was quite simple. Each column has stringFormat proprty which has to be set to something like this: {0:yyyyMMdd} I suggested on the same lines in the post #2. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |