Question: How popular is a dropdownlist with value datetime
AM and another dropdownlist with PM value in C #.
private static void FillTimeDropDown(DropDownList dropDownList)
{
TimeSpan startTime = new TimeSpan(00, 00, 00);
TimeSpan endTime = new TimeSpan(23, 59, 00);
DateTime StartTime = Convert.ToDateTime(startTime.ToString(@"hh\:mm", CultureInfo.CurrentCulture));// = new DateTime();
DateTime EndTime = Convert.ToDateTime(endTime.ToString(@"hh\:mm", CultureInfo.CurrentCulture));
int inc = 30;
while (StartTime < EndTime)
{
dropDownList.Items.Add(new ListItem { Text = StartTime.ToShortTimeString().ToString(CultureInfo.CurrentCulture), Value = StartTime.ToShortTimeString().ToString(CultureInfo.CurrentCulture) });
StartTime = StartTime.AddMinutes(inc);
}
dropDownList.Items.Add(new ListItem { Text = EndTime.ToShortTimeString().ToString(CultureInfo.CurrentCulture), Value = EndTime.ToShortTimeString().ToString(CultureInfo.CurrentCulture) });