菜鸟级:动态绑定时间

//后台
DateTime tnow = DateTime.Now;//现在时间
        int yeartimes=int.Parse(tnow.Year.ToString());//当前时间年
        int monthtimes = int.Parse(tnow.Month.ToString());//当前时间月
        ArrayList AlYear = new ArrayList();
        int i;
        for (i = yeartimes; i>= 1950; i--)
            AlYear.Add(i);
        ArrayList AlMonth = new ArrayList();
        for (i = 1; i <= monthtimes; i++)
            AlMonth.Add(i);
        DDl_SYear.DataSource = AlYear;
        DDl_SYear.DataBind();//绑定年
        DDl_EYear.DataSource = AlYear;
        DDl_EYear.DataBind();//绑定年
        DDl_SMonth.DataSource = AlMonth;
        DDl_SMonth.DataBind();//绑定月

        DDl_EMonth.DataSource = AlMonth;
        DDl_EMonth.DataBind();//绑定月
//前台
<asp:DropDownList ID="DDl_SYear" runat="server" Style="width: 60px;">
                    </asp:DropDownList>
                    年 &nbsp;<asp:DropDownList ID="DDl_SMonth" runat="server" Style="width: 40px;">
                    </asp:DropDownList>月
                    ---
                    <asp:DropDownList ID="DDl_EYear" runat="server" Style="width: 60px;">
                    </asp:DropDownList>
                    &nbsp;年 &nbsp;<asp:DropDownList ID="DDl_EMonth" runat="server" Style="width: 40px;">
                    </asp:DropDownList>月

你可能感兴趣的:(JavaScript,职场,时间,休闲)