下载列表加载年份 [英] dropdownlist loading years

查看:60
本文介绍了下载列表加载年份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何加载下拉列表,当前年份,前一年和未来两年。



请帮帮我。



先谢谢。

How to load dropdownlist, currentyear, previous year and next two years.

Please Help me.

Thanks in Advance.

推荐答案

Hope [ ^ ]可能对你有所帮助。
Hope this[^] might help you.


你有没有尝试当年-1,当年,当年+1和当年+2的简单路线?



对我来说似乎很简单。

Have you not tried the simple route of current year -1, current year, current year +1 and current year +2?

Seems straightforward to me.
<br />
DateTime.Now.Year.ToString()

当前年份。

根据需要添加和减去。

for current year.
Just add and subtract as necessary.


void BindDropdown()
   {
       for (int i = -1; i <= 2; i++)
       {
           string date = DateTime.Now.AddYears(i).ToString();
           DropDownList1.Items.Add(date);

       }
   }





在页面的表单加载事件中调用它



call it on form load event of a page


这篇关于下载列表加载年份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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