设为首页 加入收藏

TOP

C# 循环生成年份月份绑定到下拉列表框
2014-11-24 14:41:26 来源: 作者: 【 】 浏览:12
Tags:循环 生成 年份 月份 绑定 下拉

C# 循环生成年份月份绑定到下拉列表框:


string Year = DateTime.Now.Date.Year.ToString();
int intYear = Convert.ToInt32(Year)+1;
int chaYear = intYear - 2011;
string[] Yearlist;
Yearlist= new string[chaYear];
for (int i = 0; i < chaYear; i++)
{
Yearlist[i] = (2011 + i).ToString();
}
bcbyear.DataSource = Yearlist;
bcbyear.DataBind();
bcbyear.SelectedIndex = 0;


string[] MonthList;
MonthList = new string[12];
for (int i = 0; i < 12; i++)
{
MonthList[i] = (i+1).ToString("00");
}
Bdpmonth1.DataSource = MonthList;
Bdpmonth1.DataBind();
Bdpmonth1.SelectedIndex = 0;


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇第一个Struts2应用开发 下一篇C# @符号的多种使用方法

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: