Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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......
Posted
Updated 16-Jun-15 0:01am
v2
Comments
sasanka sekhar panda 16-Jun-15 6:10am    
okk you want dropdown items from 2014-2015 to which year?
Member 11769503 16-Jun-15 6:44am    
2015-2016,2016-2017...
sasanka sekhar panda 16-Jun-15 6:50am    
DropDownList1.Items.Insert(0, new ListItem("---select---"));
DropDownList1.Items.Insert(1, new ListItem("2015-2016"));
DropDownList1.Items.Insert(2, new ListItem("2016-2017"));
see solution 2 if you want to generate the years dynamically...
OriginalGriff 16-Jun-15 6:10am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
So we need to know what kind of environment you are in (website, winforms, etc), what control you are using, where your data is coming from, and so forth.
And most important, we need to know what you have tried, where you are stuck, and what help you need.
Use the "Improve question" widget to edit your question and provide better information.
Member 11769503 16-Jun-15 6:47am    
sir,am working on ASP.Net and its on winforms and data am taking from my internal server.sir i tried but i didn't succeed sorry for poor english

The following SQL will generate the list for you which you can then use as the datasource for your dropdown list

SQL
;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

It starts from last year. Change the 30 to whatever your maximum number of years should be
 
Share this answer
 
Comments
Member 11769503 16-Jun-15 7:12am    
Thank You Sir, Its great Usefull For Me....
C#
 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++;
                }
                
            }
}
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900