这是我的代码创建年+月的列表
var currentDate = DateTime.Now;
var list = new List<ArchiveViewModel>();
for (var startDate = currentDate; startDate >= new DateTime(2012, 8, 1); startDate = startDate.AddMonths(-1))
{
list.Add(new ArchiveViewModel
{
Month = startDate.Month,
Year = startDate.Year,
FormattedDate = startDate.ToString("MMMM, yyyy")
});
}
return PartialView("_ArchiveSidebar", list);
这是我在剃须刀中的代码
@foreach (var archive in Model)
{
<ul>
<li>
@Html.ActionLink(archive.FormattedDate, "Post", "Archive", new { year = archive.Year, month = archive.Month }, null)
</li>
</ul>
}
在这种情况下,结果是这样的
August, 2013
July, 2013
June, 2013
May, 2013
April, 2013
March, 2013
February, 2013
January, 2013
December, 2012
November, 2012
October, 2012
September, 2012
August, 2012
但我想要这样的东西
August, 2013 July, 2013
June, 2013 May, 2013
April, 2013 March, 2013
February, 2013 January, 2013
December, 2012 November, 2012
October, 2012 September, 2012
August, 2012
显然数据是静态的,应该怎么做?