year = DateTime.Now.Year.ToString("d");
ddlYear.Items. Add(new ListItem(year - 5, year - 5));
ddlYear.Items.Add(new ListItem(year - 4, year - 4));
ddlYear.Items.Add(new ListItem(year - 3, year - 3));
ddlYear.Items.Add(new ListItem(year - 2, year - 2));
ddlYear.Items.Add(new ListItem(year - 1, year - 1));
ddlYear.Items.Add(new ListItem(year, year));
ddlYear.Items.Add(new ListItem(year + 1, year + 1));
ddlYear.Items.Add(new ListItem(year + 2, year + 2));
ddlYear.Items.Add(new ListItem(year + 3, year + 3));
ddlYear.Items.Add(new ListItem(year + 4, year + 4));
ddlYear.Items.Add(new ListItem(year + 5, year + 5));
..........................................................................................................
ddlYear.Items. Add(new ListItem(year - 5, year - 5));
ddlYear.Items.Add(new ListItem(year - 4, year - 4));
ddlYear.Items.Add(new ListItem(year - 3, year - 3));
ddlYear.Items.Add(new ListItem(year - 2, year - 2));
ddlYear.Items.Add(new ListItem(year - 1, year - 1));
ddlYear.Items.Add(new ListItem(year, year));
ddlYear.Items.Add(new ListItem(year + 1, year + 1));
ddlYear.Items.Add(new ListItem(year + 2, year + 2));
ddlYear.Items.Add(new ListItem(year + 3, year + 3));
ddlYear.Items.Add(new ListItem(year + 4, year + 4));
ddlYear.Items.Add(new ListItem(year + 5, year + 5));
..........................................................................................................
public void GetMyMonthList(DropDownList MyddlMonthList,bool SetCurruntMonth)
{
DateTime month = Convert.ToDateTime("1/1/2000");
for (int i = 0; i < 12; i++)
{
DateTime NextMont = month.AddMonths(i);
ListItem list = new ListItem();
list.Text = NextMont.ToString("MMMM");
list.Value = NextMont.Month.ToString();
MyddlMonthList.Items.Add(list);
}
if (SetCurruntMonth == true)
{
MyddlMonthList.Items.FindByValue(DateTime.Now.Month.ToString()).Selected = true;
}
}
0 comments:
Post a Comment