using System.Globalization;
protected void Fill_DD_MM_YYYY()
{
// Date.
for (int i = 1; i <= System.DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month); i++)
{
ddlDay.Items.Add(i.ToString());
}
ddlDay.Items.Insert(0, "Select");
ddlDay.SelectedIndex = 0;
// Months.
ListItem lcc;
foreach (string item in DateTimeFormatInfo.CurrentInfo.MonthNames)
{
if (item != "")
{
lcc = new ListItem();
lcc.Text = item;
lcc.Value = item;
ddlMonths.Items.Add(lcc);
}
}
ddlMonths.Items.Insert(0, "Select");
ddlMonths.SelectedIndex = 0;
// Years.
for (int i = 0; i <= 30; i++)
{
ddlYear.Items.Add((1990 + i).ToString());
}
ddlYear.Items.Insert(0, "Select");
ddlYear.SelectedIndex = 0;
}
Days: <asp:DropDownList ID="ddlDay" runat="server"></asp:DropDownList><br/>
Months:<asp:DropDownList ID="ddlMonths" runat="server"></asp:DropDownList><br/>
Years:<asp:DropDownList ID="ddlYear" runat="server"></asp:DropDownList><br/>
protected void Fill_DD_MM_YYYY()
{
// Date.
for (int i = 1; i <= System.DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month); i++)
{
ddlDay.Items.Add(i.ToString());
}
ddlDay.Items.Insert(0, "Select");
ddlDay.SelectedIndex = 0;
// Months.
ListItem lcc;
foreach (string item in DateTimeFormatInfo.CurrentInfo.MonthNames)
{
if (item != "")
{
lcc = new ListItem();
lcc.Text = item;
lcc.Value = item;
ddlMonths.Items.Add(lcc);
}
}
ddlMonths.Items.Insert(0, "Select");
ddlMonths.SelectedIndex = 0;
// Years.
for (int i = 0; i <= 30; i++)
{
ddlYear.Items.Add((1990 + i).ToString());
}
ddlYear.Items.Insert(0, "Select");
ddlYear.SelectedIndex = 0;
}
Days: <asp:DropDownList ID="ddlDay" runat="server"></asp:DropDownList><br/>
Months:<asp:DropDownList ID="ddlMonths" runat="server"></asp:DropDownList><br/>
Years:<asp:DropDownList ID="ddlYear" runat="server"></asp:DropDownList><br/>
No comments:
Post a Comment