使用最近日期填充列表框 [英] Populating a List box with recent dates

查看:77
本文介绍了使用最近日期填充列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有趣的问题。我在大学的职业生涯工作

服务部门。我们从最近的毕业生收集数据。我是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 Career
Services department. We collect data from recent grads. I am
recreating the online survey we use. I am trying to populate the
graduation date with 4 dates. May **, June **, August **, December **.
The "**" represents the year of graduation. To prevent having to
constantly update this survey I''d like to dynamically create this
values. So at page load I want it to check the server time and only
show the months from the past year. IE since Today is June 07 the
values would read June 07, May 07, December 06, August 06. Then in
August It would read August 07, June 07, May 07, December 06. Etc... I
am trying to think of a clever way to do this and just can not do
this. Anyone have an idea???

推荐答案

" djjohnst" < dj ****** @ gmail.com写信息

新闻:11 ********************** @ p77g2000hsh .googlegr oups.com ...
"djjohnst" <dj******@gmail.comwrote in message
news:11**********************@p77g2000hsh.googlegr oups.com...

任何人有想法???
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.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.net


怎么样......


DateTime dt = DateTime.Today();


for(int iLoop = 0; iLoop< 4; iLoop ++)

{

ddlMyDropDown.Items.Add(new ListItem(String.Format(" {0:MMM yy}",

dt)));

dt = dt。 DateAdd(" MM",-3,dt);

}


Dunc
http://www.fluidfoundation.com


6月1日, 14:08,djjohnst< djjoh ... @ gmail.comwrote:
How about something like...

DateTime dt = DateTime.Today();

for (int iLoop = 0; iLoop < 4; iLoop++)
{
ddlMyDropDown.Items.Add(new ListItem(String.Format("{0:MMM yy}",
dt)));
dt = dt.DateAdd("MM", -3, dt);
}

Dunc
http://www.fluidfoundation.com

On 1 Jun, 14:08, djjohnst <djjoh...@gmail.comwrote:

我有一个有趣的问题。我在大学的职业生涯工作

服务部门。我们从最近的毕业生收集数据。我是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 Career
Services department. We collect data from recent grads. I am
recreating the online survey we use. I am trying to populate the
graduation date with 4 dates. May **, June **, August **, December **.
The "**" represents the year of graduation. To prevent having to
constantly update this survey I''d like to dynamically create this
values. So at page load I want it to check the server time and only
show the months from the past year. IE since Today is June 07 the
values would read June 07, May 07, December 06, August 06. Then in
August It would read August 07, June 07, May 07, December 06. Etc... I
am trying to think of a clever way to do this and just can not do
this. Anyone have an idea???



6月1日下午3:25,Mark Rae < m ... @ markNOSPAMrae.netwrote:
On Jun 1, 3:25 pm, "Mark Rae" <m...@markNOSPAMrae.netwrote:

" djjohnst" < djjoh ... @ gmail.com写信息


新闻:11 ********************** @ p77g2000hsh.googlegr oups.com ...
"djjohnst" <djjoh...@gmail.comwrote in message

news:11**********************@p77g2000hsh.googlegr oups.com...

任何人都有想法???
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); < br $>

}


--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.net



做得好,马克!

Well done, Mark!


这篇关于使用最近日期填充列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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