Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i use this
C#
dataGridView1.Columns.Add("Order_date", "Order date");


C#
dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Order_date"].Value = reader[5].ToString();

how to format date ?
Posted

this will help...

C#
reader Value type shoul be in DateTime Format
DateTime thisDate1 = new DateTime(2011, 6, 10);
//Console.WriteLine("Today is " + thisDate1.ToString("MMMM dd, yyyy") + ".");

dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Order_date"].Value = reader[5].ToString("MMMM dd, yyyy");



for more detail visit here....


http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx[^]
 
Share this answer
 
v3
Check this link to format DataGridview Date Column to specified Date Format.

Hope this solves the problem.

http://stackoverflow.com/questions/10644788/c-sharp-datagridview-date-time-formatting-of-a-column[^]
 
Share this answer
 
Comments
Menon Santosh 5-Sep-13 9:32am    
my +5
Thomas ktg 6-Sep-13 0:45am    
Thanks
check this out, it may be helpful.
 
Share this answer
 
hi,
you can also format date in .aspx page where you declare your columns
for example

ASP.NET
<asp:boundfield datafield="EnquiryDate" dataformatstring="{0:dd/MM/yyyy}" headertext="EnquiryDate" sortexpression="EnquiryDate" />


this formats the cell during the gridview display

hope this helps you


Happy coding:)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900