年月日 DropDownList
来源:互联网 发布:淘宝上的手工皮鞋店铺 编辑:程序博客网 时间:2024/06/05 06:20
回答问题顺手写了一个:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>年月日</title> <style type="text/css"> input, textarea {width: 100px;border-top: solid 1px #999;border-right: solid 1px #CCC;border-left: solid 1px #CCC; border-bottom: solid 1px #EEE;padding: 5px 8px;border-radius: 2px;line-height: 12px;color: #999;vertical-align: middle;} select {border-top: solid 1px #999;border-right: solid 1px #CCC;border-left: solid 1px #CCC;border-bottom: solid 1px #EEE; padding: 5px 8px;border-radius: 2px;color: #999;vertical-align: middle;} .button{width: 67px; height: 30px; border: 0 none; background-color: #FFAE00; font-weight: bold; color: white;} </style> </head><body> <form id="form1" runat="server"> <div class="content"> <p><asp:TextBox runat="server" ID="txty" style="width:60px;" Text="2008" /> <asp:TextBox runat="server" ID="txtm" style="width:60px;" Text="8" /> <asp:TextBox runat="server" ID="txtd" style="width:60px;" Text="8" /> <asp:Button runat="server" ID="btnTest" CssClass="button" Text="测试" onclick="btnTest_Click" /></p> <p> <asp:DropDownList runat="server" ID="ddl_y" Width="118" AutoPostBack="true" onselectedindexchanged="ddl_y_SelectedIndexChanged"></asp:DropDownList> <asp:DropDownList runat="server" ID="ddl_m" Width="118" AutoPostBack="true" onselectedindexchanged="ddl_m_SelectedIndexChanged"></asp:DropDownList> <asp:DropDownList runat="server" ID="ddl_d" Width="118"></asp:DropDownList> </p> </div> </form> </body></html>
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ddlBindY(); ddlBindM(); BindDays(Int32.Parse(ddl_y.SelectedValue), Int32.Parse(ddl_m.SelectedValue)); } } public DateTime tnow = DateTime.Now;//现在时间 public void ddlBindY() { ArrayList AlYear = new ArrayList(); for (int i = tnow.Year; i >= 2000; i--) AlYear.Add(i); //绑定年 ddl_y.DataSource = AlYear; ddl_y.DataBind(); ddl_y.SelectedValue = tnow.Year.ToString(); } public void ddlBindM() { ArrayList AlMonth = new ArrayList(); for (int i = 1; i <= 12; i++) AlMonth.Add(i); //绑定月 ddl_m.DataSource = AlMonth; ddl_m.DataBind(); ddl_m.SelectedValue = tnow.Month.ToString(); } private void BindDays(int year, int month) { int days = DateTime.DaysInMonth(year, month); ArrayList ardate = new ArrayList(); for (int i = 1; i <= days; i++) ardate.Add(i); ddl_d.DataSource = ardate; ddl_d.DataBind(); ddl_d.SelectedValue = tnow.Day.ToString(); } protected void ddl_y_SelectedIndexChanged(object sender, EventArgs e) { BindDays(Int32.Parse(ddl_y.SelectedValue), Int32.Parse(ddl_m.SelectedValue)); } protected void ddl_m_SelectedIndexChanged(object sender, EventArgs e) { BindDays(Int32.Parse(ddl_y.SelectedValue), Int32.Parse(ddl_m.SelectedValue)); } //绑定 protected void btnTest_Click(object sender, EventArgs e) { ddl_y.SelectedValue = this.txty.Text; ddl_m.SelectedValue = this.txtm.Text; BindDays(Int32.Parse(ddl_y.SelectedValue), Int32.Parse(ddl_m.SelectedValue)); ddl_d.SelectedValue = this.txtm.Text; }
- 年月日 DropDownList
- DropDownList自动生成年月日
- 用三个DropDownList控件选择年月日【转】
- DropDownList的年月日三联动处理方法
- DropDownList和ComboBox自动生成年月日
- ASP.NET中用三个DropDownList控件方便的选择年月日
- C# 数组作为DropDownList数据源实例---年月日加载
- 年月日
- 在ASP.NET中用三个DropDownList控件方便的选择年月日【原创】
- 在ASP.NET中用三个DropDownList控件方便的选择年月日
- 在ASP.NET中用三个DropDownList控件方便的选择年月日
- 在ASP.NET中用三个DropDownList控件方便的选择年月日
- dropdownlist
- DropDownList
- DropDownList
- DropDownList
- dropdownlist
- DropDownList
- Hadoop 解除 Name node is in safe mode
- CDbLogRoute写日志文件到MySQL数据库
- error LNK2019: 无法解析的外部符号
- JS 有时间间隔的文字滚动
- 清空 VB.net 中的 listbox
- 年月日 DropDownList
- 使用DBCC CHECKIDENT来查看和纠正IDENTITY种子值
- 创建 同义词 序列
- JDev Run OAF Page Slowly
- makefile函数集锦
- 细说Convert和Parse到底那个效率高!
- _beginthreadex 与 createthread 的区别
- 删除所标进程
- js的时间格式化