Hey akhter,
Please refer below sample.
HTML
<asp:GridView runat="server" ID="gvEmployees" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="EmployeeId" HeaderText="EmployeeId" />
<asp:BoundField DataField="Date" HeaderText="Date" />
</Columns>
</asp:GridView>
Namespaces
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
DateTime date1 = Convert.ToDateTime("10/12/2018");
DateTime date2 = Convert.ToDateTime("10/13/2018");
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] { new DataColumn("EmployeeId", typeof(int)), new DataColumn("Date", typeof(string)) });
for (DateTime i = date1; i <= date2; i = i.AddDays(1))
{
for (int j = 1; j <= 5; j++)
{
dt.Rows.Add(j, i.ToShortDateString());
}
}
this.gvEmployees.DataSource = dt;
this.gvEmployees.DataBind();
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim date1 As DateTime = Convert.ToDateTime("10/12/2018")
Dim date2 As DateTime = Convert.ToDateTime("10/13/2018")
Dim dt As DataTable = New DataTable()
dt.Columns.AddRange(New DataColumn() {New DataColumn("EmployeeId", GetType(Integer)), New DataColumn("Date", GetType(String))})
Dim i As DateTime = date1
While i <= date2
For j As Integer = 1 To 5
dt.Rows.Add(j, i.ToShortDateString())
Next
i = i.AddDays(1)
End While
Me.gvEmployees.DataSource = dt
Me.gvEmployees.DataBind()
End Sub
Screenshot