Hi nauna,
Check this example. Now please take its reference and correct your code.
HTML
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" />
<asp:TemplateField HeaderText="Date">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("date", "{0:dddd, MMM dd, yyyy}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.AddRange(new System.Data.DataColumn[] {
new System.Data.DataColumn("Id", typeof(int)),
new System.Data.DataColumn("date",typeof(DateTime)) });
dt.Rows.Add(1, new DateTime(2019, 08, 05));
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim dt As System.Data.DataTable = New System.Data.DataTable()
dt.Columns.AddRange(New System.Data.DataColumn() {
New System.Data.DataColumn("Id", GetType(Integer)),
New System.Data.DataColumn("date", GetType(DateTime))})
dt.Rows.Add(1, New DateTime(2019, 8, 5))
GridView1.DataSource = dt
GridView1.DataBind()
End If
End Sub
Output
Id | Date |
1 |
Monday, Aug 05, 2019 |