Q:

how to add yyyy/MM date in drop down list in webforms c#

I'm new in c# webforms. I'm experimenting drop down list. I want to load the current year and  month, and it's two months ago months. I want to display YEAR and MONTH only.
example: date now - 2017 / 03. two months ago are - 2017 / 02 and 2017 / 01.
default.aspx:

 <asp:DropDownList ID="ddlStartPeriod" runat="server"></asp:DropDownList>

on my page_load in default.aspx.cs:

ddlStartPeriod.Items.Add(DateTime.Now.ToString("yyyy / MM"));

I don't know what's the next move and I don't how to subtract 2 months from DateTime.Now.ToString("yyyy / MM").
Thank you in advance!

A:

Try below code
 ListItem li = new ListItem(DateTime.Now.ToString("yyyy/MM"), DateTime.Now.ToString("yyyy/MM"));
            ddlStartPeriod.Items.Add(li);
            ListItem li2 = new ListItem(DateTime.Now.AddMonths(-1).ToString("yyyy/MM"), DateTime.Now.AddMonths(-1).ToString("yyyy/MM"));
            ddlStartPeriod.Items.Add(li2);
            ListItem li3 = new ListItem(DateTime.Now.AddMonths(-2).ToString("yyyy/MM"), DateTime.Now.AddMonths(-2).ToString("yyyy/MM"));
            ddlStartPeriod.Items.Add(li3);

