Monday 9 April 2012

Binding drop down from Current year in asp.net

if (!IsPostBack)
{
  for(int i = 2000, i <= DateTime.Now.Year; i++)
  {
    MyDropDownList.Items.Add(i.ToString());
  }
  //Select the current year initially
  MyDropDownList.SelectedIndex = MyDropDownList.Items.Count - 1;
}

No comments:

Post a Comment