本文介绍了如何获得财政年度下拉列表我想要像Eg.2014-2015,2015-2016的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HI作为初学者我无法做到这一点,我希望有一个众所周知的人,会帮助我找到这个。如何获得财政年度下拉列表我想要像eg.2014-2015,2015-2016.Thank你提前......
HI as beginner i am unable to make this,i hope someone who is well known about it,will help me to find out this. how to get financial year drop down list i want like eg.2014-2015,2015-2016.Thank You in Advance......
推荐答案
;WITH CTE AS
(
SELECT YEAR(GETDATE()) - 1 AS d
UNION ALL
SELECT d + 1
FROM CTE
WHERE d < YEAR(GETDATE()) + 30
)
SELECT CAST(D AS VARCHAR) + '-' + CAST(D+1 AS VARCHAR)
FROM CTE
从去年开始。将 30
更改为您的最大年限
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int year = DateTime.Now.Year , count = 1;
DropDownList1.Items.Insert(0, new ListItem("---select---"));
for (int i = year; i < year + 3; i++)
{
DropDownList1.Items.Insert(count, new ListItem(i.ToString() + "-" + (i + 1).ToString()));
count++;
}
}
}
这篇关于如何获得财政年度下拉列表我想要像Eg.2014-2015,2015-2016的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!