当我在下拉列表中选择月份时,如何显示文本框中的天数 [英] how to display the number of days in the textbox when i select the month in the dropdownlist

查看:119
本文介绍了当我在下拉列表中选择月份时,如何显示文本框中的天数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我,当我在下拉列表中选择月份时如何显示文本框中的天数

can anyone help me,how to display the number of days in the textbox when i select the month in the dropdownlist

推荐答案

你可以使用DateTime.DaysInMonth Method [ ^ ]获取一个月内的天数并将结果分配到文本框中下拉列表的SelectedIndexChanged事件。
You can use DateTime.DaysInMonth Method[^] to get the number of days in a month and assign the result to your textbox in the SelectedIndexChanged event of your dropdown.


具体如何执行此操作取决于您首先加载到DropDownList中的内容(字符串与数字不同,将与月份不同)课程) - 以及您尝试工作的环境。基于Web的项目的解决方案将与Windows应用程序的解决方案不同(因为它将涉及Javascript来保存回发)。



但基本结构是相同:处理下拉的Changed事件,获取当前值,然后在表中查找或使用它的参数来访问天数。然后看一年检查闰年/二月问题,并设定值。



但是我们不能更具体而不了解更多关于你的环境。
Exactly how you do this depends on what you load into your DropDownList in the first place (a string would be different from a number, would be different from a Month class) - and also on what environment you are trying to work. The solution for a web based project would be different from that for a windows application (in that it would involve Javascript to save a postback).

But the basic structure is the same: handle the Changed event fro the drop down, get teh current value, then either look it up in a table or use it''s parameters to access the number of days. Then look at the year to check for leap years / February problems, and set teh value.

But we can''t be more specific without knowing a lot more about your environment.


这篇关于当我在下拉列表中选择月份时,如何显示文本框中的天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆