Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,

I have drop down lists for Month ,day and year .when i select values in drop down the date will be displayed in text box.its working fine..but im unable to validate leap year for February.
can any one help me regarding this.

im using Vb.net and below is my code for drop down list.

SQL
If Not IsPostBack Then
           ddlMonth.DataSource = Enumerable.Range(1, 12).[Select](Function(a) New With { _
	.MonthName = DateTimeFormatInfo.CurrentInfo.GetMonthName(a), _
	.MonthNumber = a _
})
ddlMonth.DataBind()
           ddlYear.DataSource = Enumerable.Range(DateTime.Now.Year, 10)
           ddlYear.DataBind()
           ddlYear.Items.Insert(0, New ListItem("--Select Year--", "0"))
           ddlday.DataSource = Enumerable.Range(1, DateTime.DaysInMonth(DateTime.Now.Year, Convert.ToInt32(ddlMonth.SelectedValue))).Reverse()
           ddlday.DataBind()
           ddlYear1.DataSource = Enumerable.Range(DateTime.Now.Year - 9, 10).Reverse()
           ddlYear1.DataBind()
           ddlday1.DataSource = Enumerable.Range(1, DateTime.DaysInMonth(DateTime.Now.Year, Convert.ToInt32(ddlMonth1.SelectedValue))).Reverse()
           ddlday1.DataBind()
           ddlYear1.Items.Insert(0, New ListItem("--Select Year--", "0"))
       End If





Protected Sub ddlYear_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlYear.SelectedIndexChanged, thnKew.DataBinding
thnKew.Text = ddlday.SelectedItem.Text + "/" + ddlMonth.SelectedValue + " /" + ddlYear.SelectedItem.Text()

End Sub
Posted

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