Click here to Skip to main content
11,495,331 members (53,419 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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.

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 28-Jun-13 20:30pm

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

  Print Answers RSS
0 Dnyaneshwar@Pune 692
1 CHill60 318
2 Sascha Lefèvre 275
3 Sergey Alexandrovich Kryukov 255
4 Nakul Chaudhari 236
0 Sergey Alexandrovich Kryukov 10,307
1 OriginalGriff 8,821
2 Sascha Lefèvre 3,889
3 Maciej Los 3,412
4 Richard Deeming 2,560


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 29 Jun 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100