Click here to Skip to main content
15,888,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In registration system, for entering date of birth it is a common practice to create a drop down list.

But it's a time taking to write down every months name in the month drop-down list, write down the list of years for the year drop-down list in the code.

Can't we create a function which generates the list of years and the months for the registration system?
Posted

Yes. you can have another option of Create XML file of year, month, day and then bind it to dropdownlist.
 
Share this answer
 
Comments
nischalinn 25-Dec-11 11:09am    
how can I do it?
nischalinn 28-Dec-11 10:52am    
Thanks for the suggestion.
Can you show me how to do it? Will you post me any link for this tutorial?
hi... see the below link.

http://www.roseindia.net/javascript/javascript-calendar.shtml[^]

or use this in source page

HTML
<input id="demo1" type="text" size="25"><a href="java<!-- no -->script:NewCal('demo1','ddmmyyyy')"><img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>
 
Share this answer
 
v2
Comments
Wendelius 19-Dec-11 14:09pm    
Edited for readability
VB
Dim type As String = ""
    Dim intialvalue As Integer
    Dim finalvalue As Integer
    Dim d As Integer
    Dim m As Integer
    Dim y As Integer

    Dim dt As DataTable
    Dim row As DataRow

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        
        With DD
            .DataSource = getData_table("Day", 1, 31)
            .DataTextField = "Name"
            .DataValueField = "ID"
            .DataBind()
        End With
        With MM
            .DataSource = getData_table("Month", 1, 12)
            .DataTextField = "Name"
            .DataValueField = "ID"
            .DataBind()
        End With
        With YYYY
            .DataSource = getData_table("year", 1950, 2001)
            .DataTextField = "Name"
            .DataValueField = "ID"
            .DataBind()

        End With
        Result.Text = DD.SelectedItem.Value.ToString & "/" & MM.SelectedItem.Value.ToString & "/" & YYYY.SelectedItem.Value.ToString

    End Sub
    Public Function getData_table(ByVal type As String, ByVal intial_value As Integer, ByVal final_value As Integer) As DataTable
        dt = New DataTable

        dt.Columns.Add("ID")
        dt.Columns.Add("Name")
        Try
            row = dt.NewRow
            row("ID") = "0"
            row("Name") = type
            dt.Rows.Add(row)
            For i = intial_value To final_value
                row = dt.NewRow
                row("ID") = final_value
                row("Name") = intial_value
                dt.Rows.Add(row)
                intial_value = intial_value + 1
                final_value = final_value - 1
            Next
        Catch ex As Exception

        End Try
        Return dt
    End Function
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900