打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
C# 数组作为DropDownList数据源实例---年月日加载
  1.  protected void Page_Load(object sender, EventArgs e)  
  2.         {  
  3.               
  4.             bindday(yearDropDL.SelectedValue, monthDropDL.SelectedValue);  
  5.         }  
  6.         public void bindday(string y, string m)  
  7.         {  
  8.             int year = int.Parse(y);  
  9.             int month = int.Parse(m);  
  10.             int[] lp = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 };  
  11.             int[] nlp = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28 };  
  12.             int[] lm = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 };  
  13.             int[] bm = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 };  
  14.             if (month == 2)  
  15.             {  
  16.                 if (year % 100 == 0)  
  17.                 {  
  18.                     if (year % 400 == 0)  
  19.                     {  
  20.                         dayDropDL.DataSource = lp;  
  21.                         dayDropDL.DataBind();  
  22.                     }else  
  23.                    {  
  24.                     dayDropDL.DataSource = nlp;  
  25.                     dayDropDL.DataBind();  
  26.                    }  
  27.                 }  
  28.                 else if (year % 4 == 0)  
  29.                 {  
  30.                     dayDropDL.DataSource = lp;  
  31.                     dayDropDL.DataBind();  
  32.                 }  
  33.                 else  
  34.                 {  
  35.                     dayDropDL.DataSource = nlp;  
  36.                     dayDropDL.DataBind();  
  37.                 }  
  38.             }  
  39.             else if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)  
  40.             {  
  41.                 dayDropDL.DataSource = bm;  
  42.                 dayDropDL.DataBind();  
  43.             }  
  44.             else  
  45.             {  
  46.                 dayDropDL.DataSource = lm;  
  47.                 dayDropDL.DataBind();  
  48.             }  
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
gridview分页模型
ArrayList用法
关于日历
计算两个日期之间相差的天数
UTC时间转换成北京时间C语言函数代码
编制万年历
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服