asp.net - Dropdownlist bind recent twelve Month-Year format in C#.NET -


i trying bind values dropdown. need bind previous 12 month-year format below

this how want bind data.

binding text: march 2015 february 2015 january 2015 december 2014 november 2014 october 2014 september 2014 august 2014 july 2014 june 2014 may 2014 april 2014

binding value: 3 2015 2 2015 1 2015 12 2014 11 2014 10 2014 9 2014 8 2014 7 2014 6 2014 5 2014 4 2014

appreciate time. thanks

simply

for (int = -11; <= 0; i++)    {       var d = datetime.now.addmonths(i);       var dstartingfromdayone = new datetime(d.year, d.month, 1);       var ds = dstartingfromdayone.tostring("mmmm yyyy");       console.writeline(ds);    } 

using linq

var last12months = enumerable.range(-11, 12).select(i => datetime.now.addmonths(i)).select(d => new datetime(d.year,d.month,1).tostring("mmmm yyyy")); 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -