码迷,mamicode.com
首页 > 其他好文 > 详细

绑定月份

时间:2017-07-09 18:18:51      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:list   默认   source   code   []   dex   ddl   div   ted   

    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;//设置默认值
        }

 

绑定月份

标签:list   默认   source   code   []   dex   ddl   div   ted   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!