<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</div>
</form>
</body>
</html>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class checkboxcheck : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string s1 = "1/1/2009";
string s2 = "1/1/2011";
DateTime _LoopDate = Convert.ToDateTime(s1);
string month = string.Empty;
DateTime _EndDate = Convert.ToDateTime(s2);
while (_LoopDate <= _EndDate)
{
System.Globalization.DateTimeFormatInfo d = new System.Globalization.DateTimeFormatInfo();
month = d.MonthNames[_LoopDate.Month - 1];
DropDownList1.Items.Add(new ListItem(month + " " + _LoopDate.Year.ToString(), _LoopDate.Month.ToString() + "" + _LoopDate.Year.ToString()));
//drpdate is dropdownlist
_LoopDate= _LoopDate.AddMonths(1);
}
}
}

No comments:
Post a Comment