本文介绍了使用最近日期填充列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个有趣的问题。我在大学的职业生涯工作 服务部门。我们从最近的毕业生收集数据。我是b $ b重新创建我们使用的在线调查。我想用4个日期来填充 毕业日期。 5月**,6月**,8月**,12月**。 **代表毕业那一年。为了防止不得不继续更新此调查,我想动态创建这个 值。因此,在页面加载时,我希望它检查服务器时间,并且仅显示过去一年中的。 IE从今天开始到6月7日, 值将于06年6月7日,07年12月6日,06月8日开始。然后在 8月它将会读到2007年6月7日, 06年5月7日,等等。我......我想要一个聪明的方法来做这件事而且不能做到这一点。任何人都有一个想法???I am having a interesting issue. I work for a University''s CareerServices department. We collect data from recent grads. I amrecreating the online survey we use. I am trying to populate thegraduation date with 4 dates. May **, June **, August **, December **.The "**" represents the year of graduation. To prevent having toconstantly update this survey I''d like to dynamically create thisvalues. So at page load I want it to check the server time and onlyshow the months from the past year. IE since Today is June 07 thevalues would read June 07, May 07, December 06, August 06. Then inAugust It would read August 07, June 07, May 07, December 06. Etc... Iam trying to think of a clever way to do this and just can not dothis. Anyone have an idea???推荐答案 List< DateTimelstDates = new List< DateTime>(); DateTime dtmStart = new DateTime(DateTime.Now.Year,DateTime。 Now.Month,1); while(lstDates.Count< 4) { if(dtmStart.Month == 5 || dtmStart.Month == 6 || dtmStart.Month == 8 || dtmStart.Month == 12) { lstDates.Add(dtmStart); } dtmStart = dtmStart.AddMonths(-1); } - http: //www.markrae.netList<DateTimelstDates = new List<DateTime>();DateTime dtmStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);while (lstDates.Count < 4){if (dtmStart.Month == 5|| dtmStart.Month == 6|| dtmStart.Month == 8|| dtmStart.Month == 12){lstDates.Add(dtmStart);}dtmStart = dtmStart.AddMonths(-1);}-- http://www.markrae.net List< DateTimelstDates = new List< DateTime>(); DateTime dtmStart = new DateTime(DateTime.Now.Year,DateTime。 Now.Month,1); while(lstDates.Count< 4) { if(dtmStart.Month == 5 || dtmStart.Month == 6 || dtmStart.Month == 8 || dtmStart.Month == 12) { lstDates.Add(dtmStart); } dtmStart = dtmStart.AddMonths(-1); } --http://www.markrae.netList<DateTimelstDates = new List<DateTime>();DateTime dtmStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);while (lstDates.Count < 4){ if (dtmStart.Month == 5 || dtmStart.Month == 6 || dtmStart.Month == 8 || dtmStart.Month == 12) { lstDates.Add(dtmStart); } dtmStart = dtmStart.AddMonths(-1);}--http://www.markrae.net 做得好,马克!Well done, Mark! 这篇关于使用最近日期填充列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
06-30 23:49