locked
Best way to default month RRS feed

  • Question

  • Hi there, new to programming so forgive what is most likely a basic question... I have the below code to show months in a dropdown.  Is there an easy way to default it to current month?  Thanks in advance...

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ddl_Monthbind();
            }

        }


        private void ddl_Monthbind()
        {
            DateTimeFormatInfo info = DateTimeFormatInfo.GetInstance(null);

            for(int i=1; i<13; i++)
            { 
            ddl_DueMonth.Items.Add(new ListItem(info.GetMonthName(i), i.ToString()));
            }

    Monday, September 29, 2014 5:01 PM

Answers

All replies