Hi nauna,
Refer below sample.
HTML
Opening Timing<asp:TextBox ID="txtopentime" runat="server" TextMode="Time"></asp:TextBox>
<br />
Closing Timing<asp:TextBox ID="txtclosetime" runat="server" TextMode="Time"></asp:TextBox>
<br />
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Selected="True" Value="15">15 Min</asp:ListItem>
<asp:ListItem Value="30">30 Min</asp:ListItem>
<asp:ListItem Value="60">60 Min</asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:Button ID="Button1" runat="server" Text="Save" OnClick="Button1_Click" />
<hr />
<asp:DropDownList ID="ddlTimer" runat="server" CssClass="center">
</asp:DropDownList>
Code
C#
protected void Button1_Click(object sender, EventArgs e)
{
ddlTimer.Items.Clear();
TimeSpan openTime = new TimeSpan(Convert.ToInt16(txtopentime.Text.Split(':')[0]), Convert.ToInt16(txtopentime.Text.Split(':')[1]), 0);
TimeSpan closeTime = new TimeSpan(Convert.ToInt16(txtclosetime.Text.Split(':')[0]), Convert.ToInt16(txtclosetime.Text.Split(':')[1]), 0);
int interval = Convert.ToInt16(RadioButtonList1.SelectedValue);
while (openTime <= closeTime)
{
string time = openTime.Hours.ToString().PadLeft(2, '0') + ":" + openTime.Minutes.ToString().PadLeft(2, '0');
ddlTimer.Items.Add(new ListItem { Text = time, Value = time });
TimeSpan span = TimeSpan.FromMinutes(interval);
openTime = openTime.Add(span);
continue;
}
}
VB.Net
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
ddlTimer.Items.Clear()
Dim openTime As TimeSpan = New TimeSpan(Convert.ToInt16(txtopentime.Text.Split(":"c)(0)), Convert.ToInt16(txtopentime.Text.Split(":"c)(1)), 0)
Dim closeTime As TimeSpan = New TimeSpan(Convert.ToInt16(txtclosetime.Text.Split(":"c)(0)), Convert.ToInt16(txtclosetime.Text.Split(":"c)(1)), 0)
Dim interval As Integer = Convert.ToInt16(RadioButtonList1.SelectedValue)
While openTime <= closeTime
Dim time As String = openTime.Hours.ToString().PadLeft(2, "0"c) & ":" + openTime.Minutes.ToString().PadLeft(2, "0"c)
ddlTimer.Items.Add(New ListItem With {.Text = time, .Value = time})
Dim span As TimeSpan = TimeSpan.FromMinutes(interval)
openTime = openTime.Add(span)
Continue While
End While
End Sub
Screenshot