Skip to content

Instantly share code, notes, and snippets.

@kristofclaes
Created June 9, 2011 06:02
Show Gist options
  • Save kristofclaes/1016152 to your computer and use it in GitHub Desktop.
Save kristofclaes/1016152 to your computer and use it in GitHub Desktop.
How one of my ex-colleagues decided to fill a dropdownlist with hour values from "08:00" to "18:00"
// How one of my ex-colleagues decided to fill a dropdownlist with hour values from "08:00" to "18:00"
for (int i = 8; i <= 18; i++)
{
ListItem li = new ListItem();
li.Value = i.ToString();
TimeSpan ts = DateTime.Now.AddHours(i) - DateTime.Now;
DateTime dtTemp = new DateTime(ts.Ticks);
li.Text = dtTemp.ToString("HH:mm");
ddlHourList.Items.Add(li);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment