A
Andrew
Miguel,
Below is the HTML and VB.net code to accomplish what you ask using a single
function. You could augment the function to account for counting up as well
as down, have both text and value for each item in the list, and so on. But
this should get you on your way.
-- Andrew
Throw this HTML into a test page:
<P>
<B>3 Drop Down Lists:</B><br>
Month:
<asp
ropDownList id="ddMonth" runat="server"></asp
ropDownList><br>
Day:
<asp
ropDownList id="ddDay" runat="server"></asp
ropDownList><br>
Year:
<asp
ropDownList id="ddYear1" runat="server"></asp
ropDownList><br>
</P>
<P>
<B>1 Drop Down List</B><br>
Year:
<asp
ropDownList id="ddYear2" runat="server"></asp
ropDownList><br>
</P>
VB.net Code used to fill based on your statements:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
' Fill three DDLists
FillDDList(Me.ddDay, 1, 31)
FillDDList(Me.ddMonth, 1, 12)
FillDDList(Me.ddYear1, 1920, Now.Year)
' Fill solo DDList
FillDDList(Me.ddYear2, 1920, Now.Year)
End If
End Sub
Private Function FillDDList(ByVal DDList As DropDownList, ByVal StartNum
As Int16, ByVal EndNum As Int16)
Dim i As Int16
Dim li As ListItem
For i = StartNum To EndNum
li = New ListItem(i)
DDList.Items.Add(li)
Next
End Function
Below is the HTML and VB.net code to accomplish what you ask using a single
function. You could augment the function to account for counting up as well
as down, have both text and value for each item in the list, and so on. But
this should get you on your way.
-- Andrew
Throw this HTML into a test page:
<P>
<B>3 Drop Down Lists:</B><br>
Month:
<asp


Day:
<asp


Year:
<asp


</P>
<P>
<B>1 Drop Down List</B><br>
Year:
<asp


</P>
VB.net Code used to fill based on your statements:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
' Fill three DDLists
FillDDList(Me.ddDay, 1, 31)
FillDDList(Me.ddMonth, 1, 12)
FillDDList(Me.ddYear1, 1920, Now.Year)
' Fill solo DDList
FillDDList(Me.ddYear2, 1920, Now.Year)
End If
End Sub
Private Function FillDDList(ByVal DDList As DropDownList, ByVal StartNum
As Int16, ByVal EndNum As Int16)
Dim i As Int16
Dim li As ListItem
For i = StartNum To EndNum
li = New ListItem(i)
DDList.Items.Add(li)
Next
End Function