Created
June 9, 2011 06:02
-
-
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"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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