for (int i = 1; i <= 24; i++)
{
hour.Items.Add(new ListItem(i.ToString(),i.ToString()));
}
hour.SelectedValue = DateTime.Now.Hour.ToString();
in the aspx page, following is the dropdown.
<asp:dropdownlist id="hour" runat="server" xmlns:asp="#unknown"></asp:dropdownlist>