I want to display time starting from 8AM To 7PM With interval 15 minutes. So:
- 8.15AM
- 8.30AM
- 8.45AM
- 9AM
- 9.15AM
- 9.30AM
In a dropdownlist. Is there any built-in control in ASP.NET other than dropdownlist
to display time?
I want to display time starting from 8AM To 7PM With interval 15 minutes. So:
In a dropdownlist. Is there any built-in control in ASP.NET other than dropdownlist
to display time?
There is nothing native to display time, you'll need to do it in a drop down list. From a usability perspective, I'd be inclined to break it into one list for hour and another for the 15 minute interval. Depending on your design, you may have the values for the lists stored in a database so can just bind the tables to the lists or alternatively just implement a loop within the code behind and add the list items programmatically.
You can find something at eworldui or codeproject Doing a search for "asp.net time picker" will reveal some others, too.
To fill your dropdownlist, you could try something like:
Dim dt As DateTime = #8:00:00 AM#
For i As Integer = 0 To 44
DropDownList1.Items.Add(dt.ToString("hh:mmtt"))
dt = DateAdd(DateInterval.Minute, 15, dt)
Next