.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Date format in datagrid

Posted By:Naresh       Posted Date: March 01, 2010    Points: 10    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  

While binding data like date type in data grid from sql server database. Along with date, default time will also be displayed. For Displaying only date or time the following data formatting string is added.

//For displaying only date:

DataFormatString ="{0:d-MMM-yyyy}"

//For displaying only time:

DataFormatString ="{0:h:mm:ss tt}"
we have to add this code in source of data grid where we display date


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend