Hi itsme,
Refer below sample.
HTML
<asp:Repeater runat="server" ID="rptTimes">
<HeaderTemplate>
<table cellspacing="0" rules="all" border="1">
<tr>
<th>
Times
</th>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label Text='<%#Eval("Start") %>' runat="server" ID="lblTime" />
To
<asp:Label Text='<%#Eval("End") %>' runat="server" ID="Label1" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
Namespaces
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] { new DataColumn("Start", typeof(string)), new DataColumn("End", typeof(string)) });
TimeSpan startTime = DateTime.Now.TimeOfDay;
TimeSpan duration = TimeSpan.FromMinutes(60);
for (int i = 0; i <= 5; i++)
{
startTime += duration.Add(duration);
dt.Rows.Add(startTime.ToString("hh':'mm"), startTime.Add(duration).ToString("hh':'mm"));
}
rptTimes.DataSource = dt;
rptTimes.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 DataTable = New DataTable()
dt.Columns.AddRange(New DataColumn() {New DataColumn("Start", GetType(String)), New DataColumn("End", GetType(String))})
Dim startTime As TimeSpan = DateTime.Now.TimeOfDay
Dim duration As TimeSpan = TimeSpan.FromMinutes(60)
For i As Integer = 0 To 5
startTime += duration.Add(duration)
dt.Rows.Add(startTime.ToString("hh':'mm"), startTime.Add(duration).ToString("hh':'mm"))
Next
rptTimes.DataSource = dt
rptTimes.DataBind()
End If
End Sub
Screenshot