Click here to Skip to main content
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)



Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 29 Jun 2013
Copyright © CodeProject, 1999-2014
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