Time Choice in ASP.NET Using DropDownLists

This sample shows how to combine the output from multiple DropDownLists in to 1 ‘Date/Time field’

<script language="VB" Runat="server">
Dim myDtTime as DateTime
Dim sDtTime as String
Sub Page_Load(Source as Object, E as EventArgs)
if not Page.IsPostBack then
	LoadHours
	LoadMinutes
end if
End Sub

Sub LoadHours()
Dim x as Integer
	For x=1 to 12
		ddlHours.Items.Add(x)
	next x
End Sub

Sub LoadMinutes()
Dim x as Integer
	For x=10 to 50 Step 10
		ddlMinutes.Items.Add(x)
	next x
End Sub

Sub doTime(Source as Object, E as EventArgs)
	sDtTime=ddlHours.SelectedItem.Text & ":" & ddlMinutes.SelectedItem.Text  & " " & ddlTime.SelectedItem.Text
	myDtTime=sDtTime
	label1.text=myDtTime
End Sub

</script>
<html>
<head>
	<meta name="GENERATOR" Content="ASP Express 3.1">
	<title>Time Choice Using DropDownLists</title>
</head>
<body>
<form id="form1" Runat="server">
<asp:DropDownList id="ddlhours" Runat="server"/>
<asp:DropDownList id="ddlMinutes" Runat="server"/>
<asp:DropDownList id="ddlTime" Runat="server">
<asp:ListItem>AM</asp:ListItem>
<asp:ListItem>PM</asp:ListItem>
</asp:DropDownList>
<asp:Button id="button1" Text="Get Time" onclick="doTime" Runat="server" />

<asp:Label ID="label1" Runat="server" />
</form>
</body>
</html>