コード例 #1
0
        void BindDate()
        {
            List <int>    dayList   = new List <int>();
            List <string> monthList = new List <string>();
            List <string> yearList  = new List <string>();

            for (int i = 1; i <= 31; i++)
            {
                if (i <= 12)
                {
                    monthList.Add(i.ToString());
                }
                dayList.Add(i);
            }

            for (int i = 1990; i < 2010; i++)
            {
                yearList.Add(i.ToString());
            }

            DayList.DataSource = dayList;
            DayList.DataBind();

            MonthList.DataSource = monthList;
            MonthList.DataBind();

            YearList.DataSource = yearList;
            YearList.DataBind();
        }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        uid    = Request.QueryString["Id"];
        action = Request.QueryString["Action"];
        if (!Page.IsPostBack)
        {
            YearList.DataSource = Enumerable.Range(startYear, DateTime.Now.Year - startYear + 1).Reverse();
            YearList.DataBind();
            MonthList.DataSource = Enumerable.Range(1, 12);
            MonthList.DataBind();
        }
        if (action == "create")
        {
        }
        else
        {
        }
        Comment.Visible = false;
        Boolean isLeapYear = IsLeapYear();
        int     year       = int.Parse(YearList.SelectedValue);
        int     month      = int.Parse(MonthList.SelectedValue);
        int     endDate    = 30;

        int[] bigMonth = { 1, 3, 5, 7, 8, 10, 12 };
        if (bigMonth.Contains(month))
        {
            endDate = 31;
        }
        if (month == 2)
        {
            if (isLeapYear == true)
            {
                endDate = 29;
            }
            else
            {
                endDate = 28;
            }
        }
        DayList.DataSource = Enumerable.Range(1, endDate);
        DayList.DataBind();
    }