asked on
ASKER
protected void Page_Load(object sender, EventArgs e)
{
List<DateTime> listDateTime = this.GetQuarter(new System.DateTime(2008, 4, 10), 3);
DropDownList3.Items.Clear();
foreach(DateTime dt in listDateTime)
{
DropDownList3.Items.Add(DateTime.Parse(dt.ToShortDateString()));
}
}
public List<DateTime> GetQuarter(DateTime startDate, int years)
{
List<DateTime> lst = new List<DateTime>();
DateTime endDate = startDate.AddYears(3);
while (startDate < endDate)
{
lst.Add(startDate);
startDate = startDate.AddMonths(3);
}
return lst;
}
OR You Can Try This Code :
protected void Page_Load(object sender, EventArgs e)
{
List<DateTime> listDateTime = this.GetQuarter(new System.DateTime(2008, 4, 10), 3);
DropDownList3.Items.Clear();
foreach(DateTime dt in listDateTime)
{
DropDownList3.Items.Add(dt.ToShortDateString());
}
}
public List<DateTime> GetQuarter(DateTime startDate, int years)
{
List<DateTime> lst = new List<DateTime>();
DateTime endDate = startDate.AddYears(3);
while (startDate < endDate)
{
lst.Add(startDate);
startDate = startDate.AddMonths(3);
}
return lst;
}
protected void Page_Load(object sender, EventArgs e)
{
List<DateTime> listDateTime = this.GetQuarter(new System.DateTime(2008, 4, 10), 3);
List<string> listStrings = new List<string>();
foreach(DateTime dt in listDateTime)
{
listStrings.Add(dt.ToShortDateString());
}
DropDownList3.DataSource = listStrings;
DropDownList3.DataBind();
}
public List<DateTime> GetQuarter(DateTime startDate, int years)
{
List<DateTime> lst = new List<DateTime>();
DateTime endDate = startDate.AddYears(3);
while (startDate < endDate)
{
lst.Add(startDate);
startDate = startDate.AddMonths(3);
}
return lst;
}
ASKER
The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.
TRUSTED BY
lst.Add(startDate);
-->
lst.Add(String.Format("{0: