What is the best way to code up a Month and Year drop down list for ASP.NET?

后端 未结 8 1501
北荒
北荒 2020-12-16 00:31

I have an internal application that I needs to have a drop down list for two date type elements: Month and Year. These values are not in

8条回答
  •  轮回少年
    2020-12-16 01:01

    Below code is for load month dropdown as Select

        private void LoadMonth()
        {
            ddlmonth.Items.Add(new ListItem("Select", 0.ToString()));
            var months = CultureInfo.CurrentCulture.DateTimeFormat.MonthNames;
            for (int i = 0; i < months.Length-1; i++)
            {
                ddlmonth.Items.Add(new ListItem(months[i], (i+1).ToString()));
            }
        }
    

提交回复
热议问题