Form Question

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:DropDownList id="ddMonth" runat="server"></asp:DropDownList><br>
Day:
<asp:DropDownList id="ddDay" runat="server"></asp:DropDownList><br>
Year:
<asp:DropDownList id="ddYear1" runat="server"></asp:DropDownList><br>
</P>
<P>
<B>1 Drop Down List</B><br>
Year:
<asp:DropDownList id="ddYear2" runat="server"></asp:DropDownList><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
 
M

Miguel Dias Moura

Hello,

i need to insert 2 things in a web site form:

1. 3 DropDownLists with Day, Month and Year (since 1920). I don't want to
fill everything.
Do you know if there is something i can use and that people usually use
it for this?

2. I want just one DropDownList. This one shows year. The problem is similar
to above.

I need to have this done as fast as possible. Can you help me out please?

I am working in ASP.net / VB

Thank You Very Much,
Miguel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top