0
Question: As popular a dropdownlist worthwhile datetime
AM and other 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) });
Jesus, I suggest you write the statement of your question (I will edit to improve the formatting of the code), to make it as readable as possible.
– Tuxpilgrim