• webform的三级联动


    webform的三级联动

    与winform一样,只不过需把DropDownList的AutoPostBack属性改为True。

    *简单日期的编写方法:
    用是三个DropDownList分别代表年月日,用for循环进行数据绑定,同时并对日进行判断
    复制代码
      for (int i = DateTime.Now.Year; i >= 1900; i--)
                {
                    ListItem li = new ListItem(i.ToString());
                    Year_Dr.Items.Add(li);
                }
    
                for (int i = 1; i <= 12; i++)
                {
                    ListItem li = new ListItem(i.ToString());
                   Mouth_dr.Items.Add(li);
                }
    
                Days();
               Mouth_dr.SelectedValue = DateTime.Now.Month.ToString();
               Day_dr.SelectedValue = DateTime.Now.Day.ToString();
            }
    
            Year_Dr.SelectedIndexChanged +=Year_Dr_SelectedIndexChanged;
            Mouth_dr.SelectedIndexChanged +=Mouth_dr_SelectedIndexChanged;
    //方法及事件
    
     private void Days()
        {
            for (int i = 1; i <= 31; i++)
            {
                int year = Convert.ToInt32(Year_Dr.SelectedValue);
                int mouth = Convert.ToInt32(Mouth_dr.SelectedValue);
                if (mouth == 1 || mouth == 3 || mouth == 5 || mouth == 7 || mouth == 8 || mouth == 10 || mouth == 12)
                {
                }
                else if (mouth == 4 || mouth == 6 || mouth == 9 || mouth == 11)
                {
                    if (i == 31)
                    {
                        break;
                    }
                }
                else if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
                {
                    if (i == 30)
                    {
                        break;
                    }
                }
                else
                {
                    if (i == 29)
                    {
                        break;
                    }
                }
                ListItem li = new ListItem(i.ToString());
                Day_dr.Items.Add(li);
            }
        }
    
    void Mouth_dr_SelectedIndexChanged(object sender, EventArgs e)
    {
        Day_dr.Items.Clear();
        Days();
        
    }
    
    void Year_Dr_SelectedIndexChanged(object sender, EventArgs e)
    {
        Mouth_dr.Items.Clear();
        Day_dr.Items.Clear();
        for (int i = 1; i <= 12; i++)
        {
            ListItem li = new ListItem(i.ToString());
            Mouth_dr.Items.Add(li);
        }
    
        Days();
    }
  • 相关阅读:
    oracle锁---原理篇
    SML + NL + HJ
    Oracle中varchar,varchar2,nvarchar,nvarchar2的区别
    oracle 一致读原理
    commit 流程
    IMPDP NETWORK_LINK参数
    WINDOWS访问虚拟机RedHat搭配的Apache2服务器
    初识malloc函数
    好吧,又失眠
    休息一天
  • 原文地址:https://www.cnblogs.com/1030351096zzz/p/6237410.html
Copyright © 2020-2023  润新知