首页 > 其他 > 详细

绑定月份

时间:2017-07-09 18:13:04      阅读:183      评论:0      收藏:0      [点我收藏+]
    private void GetMonth()
        {
            int index = 0; //定义索引
            DateTime now = DateTime.Now;
            string month = now.Month.ToString();
            if (Convert.ToInt32(month)<10)
            {
                month = "0" + month + "";
            }
            else
            {
                month = month + "";
            }
            string[] MonthList;
            MonthList = new string[12];
            for (int i = 0; i < 12; i++)
            {
                MonthList[i] = (i + 1).ToString("00") + "";
                if (MonthList[i]==month)
                {
                    index = i;//设置索引
                }
            }
            ddlMonth.DataSource = MonthList;
            ddlMonth.SelectedIndex = index;//设置默认值
        }

 

绑定月份

原文:http://www.cnblogs.com/rwh871212/p/7142143.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!