private void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ddlMonth.DataSource = Enumerable.Range(1, 12).Select(a => new { MonthName = DateTimeFormatInfo.CurrentInfo.GetMonthName(a), MonthNumber = a //DataTextField = DateTimeFormatInfo.CurrentInfo.GetMonthName(a), //DataValueField = a } ); //If this code is not working then try the above code in the loop. ddlMonth.DataTextField = "MonthName"; ddlMonth.DataValueField = "MonthNumber"; ddlMonth.DataBind(); ddlYear.DataSource = Enumerable.Range(DateTime.Now.Year - 99, 100).Reverse(); ddlYear.DataBind(); ddlday.DataSource = Enumerable.Range(1, DateTime.DaysInMonth(DateTime.Now.Year, Convert.ToInt32(ddlMonth.SelectedValue))); ddlday.DataBind(); } } protected void ddlMonth_SelectedIndexChanged(object sender, EventArgs e) { ddlday.DataSource = Enumerable.Range(1, DateTime.DaysInMonth(DateTime.Now.Year, Convert.ToInt32(ddlMonth.SelectedIndex + 1))); ddlday.DataBind(); } }
System.DateTime date1 = new System.DateTime(2012, 1, 1); System.DateTime date2 = System.DateTime.Now.Date; // diff1 gets 242 days System.TimeSpan diff1 = date2.Subtract(date1);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)