How to Format Date in GridView Control
Author: DevASP Team
Download Source Code : 680_FormatDate.zip
In this article I will try to explain you how you can format date in a GridView Control while binding your data to column.
To begin with this application create a new website in ASP.Net 2.0 using C# as code behind and add the following code in aspx page:
You will see that I have used the label control and itemtemplate and set its text to bind column and there I have used the Convert.ToDateTime method that will change the value to date time and will format it into the way that we want to be displayed on form. Now on page load add the following code:
You need to import the System.Data.SqlClient namespace to use the sql namespace methods.