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