.aspx
<asp:DropDownList runat="server" ID="ddlYear"></asp:DropDownList>
<asp:DropDownList runat="server" ID="ddlMonth"></asp:DropDownList>
.aspx.cs
private void LoadYearAndMonth()
{
string Year = DateTime.Now.Date.Year.ToString();
int intYear = Convert.ToInt32(Year) + 10;
int chaYear = intYear - 2011;
string[] Yearlist;
Yearlist = new string[chaYear];
for (int i = 0; i < chaYear; i++)
{
Yearlist[i] = (2011 + i).ToString();
}
ddlYear.DataSource = Yearlist;
ddlYear.DataBind();
ddlYear.SelectedIndex = 0;
string[] MonthList;
MonthList = new string[12];
for (int i = 0; i < 12; i++)
{
MonthList[i] = (i + 1).ToString("00");
}
ddlMonth.DataSource = MonthList;
ddlMonth.DataBind();
ddlMonth.SelectedIndex = 0;
}
1万+

被折叠的 条评论
为什么被折叠?



