Welcome

Hello, Welcome to my blog. If you like feel free to refer others

Monday 26 November 2012

Dropdown list binding with financial year

Problem: Sometimes we need to get a result of financial years(...2011-2012, 2012-2013, 2013-2014) starting from the date given by me to till 5 year in a dropdown list.

Solution: Lets say we received the given date from text box:-
 
DateTime GivenDate = Convert.ToDateTime(textBox1.Text);
int GivenYear = GivenDate.Year;
 
for(int i=0; i<5; i++)
{
comboBox1.Items.Add(GivenYear + i + "-" + (GivenYear + 1 + i));
}

Hope this will solve your problem.....

No comments:

Post a Comment