Showing posts with label Binding drop down from Current year in asp.net. Show all posts
Showing posts with label Binding drop down from Current year in asp.net. Show all posts

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;
}