ASP.NET中如何实现日期下拉框呀?

来源:百度知道 编辑:UC知道 时间:2024/05/22 14:31:01

我的DropDownList1是月,DropDownList2是年,DropDownList3是日。年和月用反了。呵呵
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
int i;
ArrayList month=new ArrayList();
for(i=1;i<=12;i++)
num.Add(i);
this.DropDownList1.DataSource=month;
this.DropDownList1.DataBind();
//以上初始化月
int j;
ArrayList year=new ArrayList();
for(j=2000;j<=2020;j++)
year.Add(j);
this.DropDownList2.DataSource=year;
this.DropDownList2.DataBind();
//以上初始化年
this.DropDownList1.AutoPostBack=true;
this.DropDownList2.AutoPostBack=true;
}
}

private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
day(this.DropDownList1.SelectedValue,Convert.ToInt16(this.DropDownList2.SelectedValue));
}

private void day(string d,int year)
{
switch(d)